Given a list of tuple:
data = [('David', '5239980'), ('Bob', '4562345'), ('Jenny', '2541273')]
What is the easiest way of getting the 2nd element?
E.g. if I want to get the corresponding number value to David or Bob?
Given a list of tuple:
data = [('David', '5239980'), ('Bob', '4562345'), ('Jenny', '2541273')]
What is the easiest way of getting the 2nd element?
E.g. if I want to get the corresponding number value to David or Bob?
I use python list comprehension
[y for x, y in data if (x == 'David' or x == 'Bob')]