I have a list:
lst=[1,1,2,2,3,3,4,4]
After this code:
lst = list(set(lst))
print(lst)
I get this output:
[1, 2, 3, 4]
Also, I have another list:
lst=[6,6,7,7,8,8,9,9]
After this code:
lst = list(set(lst))
print(lst)
I get this output
[8, 9, 6, 7]
This output is not in the original order of the list ([6,7,8,9]
). But I expected to get this order.
Also, I have a another list:
lst=[6,6,7,7,8,8,9,9,1,1]
After this code:
lst = list(set(lst))
print(lst)
I get this output:
[1, 6, 7, 8, 9]
But I want the output as [6, 7, 8, 9, 1]
.
So my question is: how can I take the set of a list while retaining the original order order of list? Thanks in advance.