How to find the index of a list inside a list (sublist) in Python

1 Answer

0 votes
lst = ['a', 'c', 'd', 'f', ['x', 'y'], 'g', 'h', 'k']

index = lst.index(['x', 'y'])

print("The index of ['x', 'y'] is: ", index)


'''
run:

The index of ['x', 'y'] is:  4

'''

 



answered Feb 15, 2019 by avibootz
...