How to get the first element of each tuple in a list of tuples in Python

1 Answer

0 votes
lst_tpl = [(1, 2, 3), (4, 5, 6, 7), (8, 9)] 
 
result = [tpl[0] for tpl in lst_tpl]

print(result)
 

  
  
  
'''
run:
  
[1, 4, 8]
  
'''

 



answered Jul 25, 2022 by avibootz
...