DEV Community

Discussion on: 11 Tips And Tricks To Write Better Python Code

Collapse
 
pat_loeber profile image
Patrick Loeber

Good point! Probably a set would be even better to store the colors here. I just wanted to show a dummy example, and in "real life" code a lot of times you stumble on situations where you have a list that you want to check...

Collapse
 
jingxue profile image
Jing Xue

Understood. Actually come to think of it, when you have only a few items, a list is not necessarily slower and definitely more memory efficient than a set. :-)