2
I am doing an exercise where I must create a function that removes repeated items from a list and returns this ordered list.
My code removes only a few repeated items, but leaves others. I know there are other solutions without the use of del
, but I’m curious about what I’m missing here, I also accept tips that don’t involve the workout solution.
Follows the code:
def remove_repetidos(lista):
for itens in lista:
if lista.count(itens) == 1:
continue
lista.remove(itens)
return sorted(lista)
In case I put [7,3,33,12,3,3,3,7,12,100]
as parameter it returns [3, 3, 3, 7, 12, 33, 100]
.