In this Python list program, we will take a user input as a list and find the list in a list of lists whose sum of elements is the highest with the help of the below-given steps.
List of lists having sum of list elements:
Steps to solve the program
- Take user input as a list of lists.
- Use the built-in max() function and set key=sum to get the list having the maximum sum of elements.
- Print that list.
#Input list
list1 = [[11, 2, 3], [4, 15, 2], [10, 11, 12], [7, 8, 19]]
#Printing output
print(max(list1,key=sum))
Output :
[7, 8, 19]
Related Articles
Python program to find the items that start with a specific character from a given list.
Python program to count empty dictionaries from the given list.
Python program to remove consecutive duplicates of given lists.
Python program to pack consecutive duplicates of given list elements into sublists.
Python program to insert items at a specific position in the list.