DEV Community

Discussion on: 5 Python Tricks in one line. Beginner vs Professional

Collapse
 
ruudvanderham profile image
ruudvanderham

Under Python 3.6 and higher this one liner will also maintain the order
new = list(dict.fromkeys(fruits))
and it is O(n)!

Collapse
 
vadimkolobanov profile image
Vadim Kolobanov

Thank you all so much) You really help all readers to become a little more literate

Collapse
 
kbauer profile image
kbauer

Interesting to know, but hard to read :/ If I'd see this in the code I wouldn't be aware, that preserving the order is an intent here.

Thread Thread
 
ruudvanderham profile image
ruudvanderham

Just adding a comment would help.

Thread Thread
 
vadimkolobanov profile image
Vadim Kolobanov

Guys, I pointed out your help in the article and asked you to pay attention to the comments) So thank you very much! Many opinions, and various practices make this article even better)