Contact: aviboots(AT)netvision.net.il
41,231 questions
53,733 answers
573 users
list_of_tuples = [(3, 'python'), (7, 'c'), (8, 'c++'), (5, 'java'), (9, 'c#')] index = [idx for idx, tpl in enumerate(list_of_tuples) if tpl[1] == 'c++'] print(index) print(index[0]) ''' run: [2] 2 '''
list_of_tuples = [(3, 'python'), (7, 'c'), (8, 'c++'), (5, 'java'), (9, 'c#')] index = [tpl[1] for tpl in list_of_tuples].index('c++') print(index) ''' run: 2 '''