Nov-09-2021, 07:39 PM
You can step through the code at the following link
visualize code execution
visualize code execution
Remove an item from a list contained in another item in python
|
||||||||||||
Nov-09-2021, 07:39 PM
You can step through the code at the following link
visualize code execution
Nov-09-2021, 07:52 PM
(This post was last modified: Nov-09-2021, 07:55 PM by Gribouillis.)
I have an even more avant-garde version that works for me. I don't know if this is documented somewhere
Nov-09-2021, 09:54 PM
(This post was last modified: Nov-09-2021, 09:55 PM by CompleteNewb.)
(Nov-09-2021, 07:17 PM)deanhystad Wrote: Ahh, I understand your confusion now. It is clever, and I guess potentially confusing. Okay, thanks, but how would you write it if you don't want the "for r in roots" on the same line as the "any(s.issubset( r )"? I am trying to rewrite it that way, because I still have a hard time understanding the " line ??? of the for loop" and I just can't do it.
Nov-09-2021, 10:19 PM
(This post was last modified: Nov-09-2021, 10:21 PM by deanhystad.)
You can replace the "any" with a loop, but you need the "for r in roots".
Nov-09-2021, 10:52 PM
Also
Nov-11-2021, 12:00 AM
(Nov-09-2021, 10:19 PM)deanhystad Wrote: You can replace the "any" with a loop, but you need the "for r in roots". Well i tried rewriting it from my own comprehension and i came up with that which is in my mind the same thing, but it doesn't work??? What am i missing?
Nov-11-2021, 01:10 AM
The else needs to be attached to for loop, not the if statement. Read about for..else.
Nov-11-2021, 02:16 AM
Thank you very much everyone. Your help has been very helpful! I really appreciated it
Nov-11-2021, 06:43 AM
(This post was last modified: Nov-11-2021, 06:45 AM by Gribouillis.)
@CompleteNewb WARNING If you don't sort the list of sets by decreasing lengths, the algorithm may fail. It will keep sets that are subsets of other sets that come later in the list.
| ||||||||||||
|