+ 1

what is the python program to print second smallest elemnt in a list

8th Nov 2016, 2:06 AM
Anju kv
Anju kv - avatar
2 ответов
+ 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
8th Nov 2016, 3:00 AM
Chris
Chris - avatar
0
Sort the list and pick the list[1] element. It's the easiest way
8th Nov 2016, 2:11 AM
Narciso Nuñez Arias
Narciso Nuñez Arias - avatar