Q:

Python - how to find the position of the second lowest value in a list

I have the following list:
list = [7,3,6,4,6]

I know I can use list.index(min(list)) to find the position of the lowest number in the list, but how do I use it to find the second lowest?

A:

don't use list as a var name
edit, originally misread as index of 2nd highest - fixed now, thanx Jean-François Fabre
lst = [7,3,6,4,6]

lst.index(sorted(lst)[1])

Out[161]: 3

lst[3]
Out[162]: 4

sorted(lst)
Out[163]: [3, 4, 6, 6, 7]

the above has a problem with repeated numbers in the input list, by using .index you get the index of the 1st match
lst = [1, 1, 7,3,6,4,6]

lst.index(sorted(lst)[1])
Out[9]: 0                  # 0 is wrong, the postion of the 2nd smallest is 1  

I think this fixes it
n = 1
sorted([*enumerate(lst)], key=lambda x: x[1])[n][0]
Out[11]: 1  

looking at the pieces  
[*enumerate(lst)]
Out[12]: [(0, 1), (1, 1), (2, 7), (3, 3), (4, 6), (5, 4), (6, 6)]

enumerate pairs a count with the values in the input lst, * forces 'unpacking' of the enumerate object, the outer sq brackets 'catch' this output in a list 
inside Python builtin sorted the 2nd argument key=lambda x: x[1] tell it to look in the 2nd position of the tuples from [*enumerate(lst)] which are the numbers from lst 
sorted([*enumerate(lst)], key=lambda x: x[1])
Out[13]: [(0, 1), (1, 1), (3, 3), (5, 4), (4, 6), (6, 6), (2, 7)]  

the indexing that list with [n][0] gets the n-th sorted tuple, and takes the 1st value from the tuple which is the index asigned in enumerate

