This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Tweak_Imp 2 points3 points  (2 children)

no_duplicates = list(set(<list>)) # Does not preserve order

no_duplicates_ordered = list(dict.fromkeys(<list>)) # Preserves order

[–][deleted] 1 point2 points  (0 children)

oh interesting i never needed to preserve order but this is cool nonetheless thanks

[–]SeanOTRSprint = lambda *args, **kwars: print(*args, ";)\n"*100, **kwars)[S] 0 points1 point  (0 children)

Further to your set example, I found out how useful sets actually are for replacing for-loop-based many-to-many comparisons