[Solved] How to find the nearest element in a list [closed]


Use

pos = my_list.index('asd')
nearest = my_list[pos + 1]

Note pos is 3 for the 4th element as Python is 0- based. Note avoid using list for variables as this name has a special meaning in Python.

1

solved How to find the nearest element in a list [closed]