0
list = [1, 2, 6, 2, 9, 8, 1]
   for i in range(0, len(list)):
     for j in range(1, len(list)):
        if list[i] == list[j]:
          list.pop(j)
          print(list)

I have tried by using this code

  • 2
    Don't remove items from a list while iterating over it and don't call your list `list`. – Guy Aug 14 '22 at 11:43
  • Why dont you use set(your_list_name), it will remove all the duplicate elements as ->set<- by nature is unique – Abhishek Aug 14 '22 at 14:13

0 Answers0