How to find the indexes of a list of items in another list with Python

1 Answer

0 votes
lst1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]
lst2 = [30, 90, 100, 80]

dic = dict(zip(lst1, range(len(lst1))))

indexes = [dic[val] for val in lst2]

print(indexes )

       
    
                  

'''
run:

[2, 8, 9, 7]

'''

 



answered Feb 22, 2023 by avibootz

Related questions

...