Reputation:
Suppose i have a list;
list1 = [[1,2,3],[5,6,7], [7,8,9]]
When i execute the following line of code
for x in list1: sum(x)
I receive
6
18
24
I would like to sum all numbers in list1 using one comprehension and two sum() methods. That will also work if one of the list elements is a list of float objects.
Upvotes: 0
Views: 94