my_list = [1, 2, 4, 4, 1, 4, 2, 6, 2, 9]
my_list.sort()
print(my_list)
list2 = []
for i in my_list:
if my_list[i] not in list2:
list2.append(my_list[i])
print(list2)
list2.sort()
my_list = list2[:]
print("The list with unique elements only:")
print(my_list)
The code outputs 1,2,4 and then 9 from the new list in that order (missing the 6) any ideas what's going wrong here?