How to access tuples in a list in Python

Accessing tuples in a list returns a new list that contains each item at the desired index of each tuple in the list. For example, accessing the second value in each tuple in [(1, 2), (3, 4), (5, 6)] returns [2, 4, 6].

Solution for How to access tuples in a list in Python : You can use a list comprehension to access tuples in a list Use the list comprehension syntax [tuple[index] for tuple in list] to return a list of the items in index of each tuple in list.


how-to-access-tuples-in-a-list-in-python