Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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']
Source by www.kite.com #
 
PREVIOUS NEXT
Tagged: #extract #elements #list #tuples
ADD COMMENT
Topic
Name
7+8 =