hi everyone this is my code to remove repeated items in a list of numbers:
numbers=[5,2,2,2,2,2,34,5,46,78,65,34,78,34,3,2,47,5,8,76]
for item in numbers:
if numbers.count(item)>1:
numbers.remove(item)
print(numbers)
and the result is this: [2, 2, 46, 65, 78, 34, 3, 2, 47, 5, 8, 76]
still has repeated items. but if i change the code in this way: for item in numbers[ : ] it would work and the result is: [46, 65, 78, 34, 3, 2, 47, 5, 8, 76]
what s the difference?