0
my_list = [1, 2, 3, 3, 4, 4, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6]
for item in my_list:
    if my_list.count(item) > 1:
        my_list.pop(item)


print(my_list) # => actual result - [1, 2, 3, 4, 5, 6, 6, 6, 6]
ggorlen
  • 44,755
  • 7
  • 76
  • 106
  • 2
    Welcome to SO! `.pop` takes an index, not an element. It's also a bad idea to mutate a list while iterating over it. A better way to dedupe is `list(set(your_list))`. – ggorlen Sep 03 '19 at 19:30
  • 1
    Possible duplicate of [Removing from a list while iterating over it](https://stackoverflow.com/questions/6500888/removing-from-a-list-while-iterating-over-it) – Patrick Haugh Sep 03 '19 at 20:10

0 Answers0