list of tuples get first element code example
Example 1: how to extract the first elements from a list of tuples
tuple_list = [("a", "b"),("c", "d")]
first_tuple_elements = []
for a_tuple in tuple_list:
first_tuple_elements.append(a_tuple[0])
print(first_tuple_elements)
#OUTPUT: ['a', 'c']
Example 2: get first element of tuple python
firstItem = tupple[0]