A common problem when dealing with lists is deduping or removing duplicate items. For a completely unique list there are a few ways to accomplish this in Python.
The Fastest Way to Dedupe
>>> yourList = list(set(yourList))
All we're doing is leveraging Python's built in functions: set() and list(). The 'set()' function will convert your list into type set; and by definition, sets only have unique entries, so this will automatically remove any duplicate items in your original list.
Since you probably still want a list, we convert the set back to a list with the 'list()' function. The list function simply overrides the set type, with the list type.
Preserving Order
Sometimes you'll want to preserve the order of a list. Since sets need to be hashable they may or may not preserve the original order of your list. To solve for this we write a slightly longer script
>>> yourList = [0,1,2,2,3,5,5,5,7,9,9] >>> uniqueList = [] >>> for value in yourList: >>> .... if value not in uniqueList: >>> ........ uniqueList.append(value) >>>uniqueList [0,1,2,3,5,7,9]
Here we create a new container (uniqueList) after we've processed the original list (yourList). Then we use a for loop to go through every value in the original list (yourList). If we haven't seen the value before, we add it to the new list (uniqueList). If we've seen it before, we disregard it and move to the next value in the original list (yourList).
In the end, you're left with a completely unique deduped list in the same order the original list was in.

. By default python's 