Jun-14-2019, 03:13 PM
hi, there! i am new to python and i was trying to remove duplicate numbers in a list using for loop. but the code doesn't quite work
this is what i get when i run it.
numbers = [3, 3, 20, 6, 10, 6, 5, 5, 7, 10, 7, 19, 19, 20] for x in numbers: if numbers.count(x) > 1: numbers.remove(x) print(numbers)it doesn't remove all the duplicates.
this is what i get when i run it.
Output:[3, 6, 6, 5, 10, 7, 19, 20]