I'm pretty new to Python and I was trying to figure out a way to delete duplicates from a List. I found other ways to do it, but I would like to know why my way does not work.
numbers = [1, 1, 1, 1]
for number in numbers:
if numbers.count(number) > 1:
numbers.remove(number)
print(numbers)
The Output is: [1, 1]
Process finished with exit code 0
It works sometimes, but not all the times.