What is the best option to retrieve only non-duplicate elements from a Python list? Say I have the following list:
lst = [1, 2, 3, 2, 3, 4]
I w
This is a breeze with a list comprehension:
>>> lst = [1, 2, 3, 2, 3, 4] >>> [x for x in lst if lst.count(x) == 1] [1, 4] >>>
Also, I recommend that you do not name a variable list--it overshadows the built-in.
list