Is there a way to preserve the original order of elements from the list? with my code below I get this as the output
Values: [1, 3, 0, 1, 4, 1, 1, 2, 2, 5, 4, 3, 1, 3, 3, 4, 2, 4, 3, 1, 3, 0, 3, 0, 0]
Clean: [5, 2, 4, 1, 3, 0]
I need [1, 2, 0, 4, 5, 3]
as the "clean" list
def remove_duplicates(lst)
i = len(lst)
while i>0:
while values.count(values[i]>1:
values.remove(values[i])
i-=1
i-=1
return
The question seems pretty simple to solve with for loops and a new list output but I am required to use while loops and stick with only one list.
def remove_duplicates(lst):
new =[]
for x in lst:
if x not in lst:
new.append(x)
return new