Sorry in advance, but I\'m new to Python. I have a list of tuples, and I was wondering how I can reference, say, the first element of each tuple w
tuples
tuple
You can get a list of the first element in each tuple using a list comprehension:
>>> my_tuples = [(1, 2, 3), ('a', 'b', 'c', 'd', 'e'), (True, False), 'qwerty'] >>> first_elts = [x[0] for x in my_tuples] >>> first_elts [1, 'a', True, 'q']