There is a list of lists. How can I get a list of only the first elements of internal lists without using this construction?

main_list = [[], [], []] def get_first_item_list(): list = [] for main in mail_list: list.append(main[0] return list 

More precisely not a list of lists, but a list of tuples

 [(1157, 'AMD FirePro 2270'), (1156, 'AMD FirePro 2270 1GB Edition'), (1155, 'AMD FirePro 2270 PCIe x1')] 
  • Write the input list of lists, main_list - S. Nick main_list
  • @ S.Nick below is a list of tuples - danilshik

1 answer 1

 main_list = [(1157, 'AMD FirePro 2270'), (1156, 'AMD FirePro 2270 1GB Edition'), (1155, 'AMD FirePro 2270 PCIe x1')] [ i[0] for i in main_list] [1157, 1156, 1155]