May-15-2021, 06:27 AM
'Bob'
is not in the listprint('Bob' == ('Bob', '4562345'))
Output:False
('Bob', '4562345')
is in the listdata = [('Jill', '5239980'), ('Bob', '4562345'), ('Jenny', '2541273')] print(data.index(('Bob', '4562345')))
Output:1
To find the index of the tuple that 'Bob'
is inside you would need to loop through the list comparing the first index item of each against 'Bob', you can use enumerate to get the index as you loop through.