+ 1
what is the python program to print second smallest elemnt in a list
2 Respuestas
+ 1
x.sort() will change your list inside list x, so you cannot go back to the initial order. to avoid it, you can do:
sorted(list(set(x))) [1]
that will not only return second smallest element, but also is immune to lists with repetitions
0
Sort the list and pick the list[1] element. It's the easiest way