Iterating through a tuple of tuples

Asked by At

I have a tuple of tuples and I want to get the second item of its tuple and I am pretty stack on it.Example of what I want:


and I want to get:


2 Answers

JohnO On

List comprehension:

my_list = [entry[1] for entry in t]
U9-Forward On

Try this using a list comprehension:

print([x for _, x in t])

Another (not really recommended solution):

print(list(map(lambda x: x[1], t)))

Both Output:

['a', 'b', 'c', 'd', 'e']