I am new to python and currently learning the basics.
I want to remove duplicates in a list.
Here is my code:
numbers = [2, 4, 5, 6, 9, 4, 0, 8, 2, 4]
for item in reversed(numbers):
if numbers.count(item) > 1:
numbers.remove(item)
print(numbers)
The result I expected is
[2, 4, 5, 6, 9, 0, 8]
However, I got instead
[5, 6, 9, 0, 8, 2, 4]
I don't know why this happened since I use reversed iterator. So any explanation is appreciated.