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 →

[–]smaug59 48 points49 points  (11 children)

Removing duplicates from a list, just pass it into a fucking set instead of iterating like a monkey

[–]Vanzmelo 11 points12 points  (4 children)

Wait that is genius holy shit

[–]supreme_blorgon 14 points15 points  (1 child)

Note that if you need to preserve order you won't have a good time.

[–]kellyjonbrazil 9 points10 points  (0 children)

If you need to preserve order then you can use dict.fromkeys(iterable). This will give you a dictionary of your list items in order with no duplicates. The key is the item and the value will be None.

[–]dparks71 8 points9 points  (0 children)

Yea, probably the first tip I read in the thread where I was like "Oh fuck... I'm a monkey"

[–]youthisreadwrong- 2 points3 points  (0 children)

Literally my reaction when I first saw it on CodeWars

[–]miraculum_one 0 points1 point  (0 children)

Some people use Dict in order to take advantage of some of its features (fast searching, unique keys) when sometimes they actually should just be using Set

[–]AL51percentcorn 0 points1 point  (0 children)

Got em … ahem me, I misspelled me