How to get the second 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[1] for tpl in lst_tpl]

print(result)
 

  
  
  
'''
run:
  
[2, 5, 9]
  
'''

 



answered Jul 25, 2022 by avibootz
...