To remove duplicates from List use, set as set does not contain duplicates and also is unordered.
For Example:
Example = ['a','b','c','d','a','a','b','c','d']
list(set(Example))
Output:
['b', 'd', 'c', 'a']
from collections import OrderedDict
OrderedDict((u, True) for u in Example).keys()
Output:
odict_keys(['a', 'b', 'c', 'd'])
Here, OrderedDict remembers the insertion order of keys, and does not change it when a value at a particular key is updated. We use True as one value was needed to unpack the list, which is shown below without using True.
from collections import OrderedDict
OrderedDict((u) for u in Example).keys()
Output
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-12-ce40dd697e48> in <module>
1 from collections import OrderedDict
----> 2 OrderedDict((u) for u in Example).keys()
ValueError: need more than 1 value to unpack