Exercising order list

0

Good afternoon,

I'm developing an exercise and at one point I have to sort a list and remove repeated elements, for this I perform the conversion to set and then convert to list again:

    def remove(lista):
       lista2 = set(lista)
       lista = list(lista2)
       return lista

However, by performing a test, I always get an unexpected result in the conversion of [7,3,33,12,3,3,3,7,12,100] rather than [3,7,12,33,100] , I get as a result [33, 3, 12, 100, 7], can anyone help me to find this error?     

asked by anonymous 13.01.2018 / 18:25

1 answer

0

It's not a bug, you just did not sort the list after removing the duplicates:

def remove(lista):
   return sorted(set(lista)) # <--- ordena lista

DOCS

    
13.01.2018 / 18:28