How to get the size of a list of lists in Python

The size of a list of lists is the total number of elements contained within all lists in the list of lists. For example, the size of the list of lists [[1, 2, 3], [], [4, 5], [6], [7, 8, 9, 10]] is 10.

Solution for How to get the size of a list of lists in Python : You can use functools.reduce() with len() to get the size of a list of lists Call functools.reduce(function, sequence, initial) with function as the lambda expression lambda count, element: count + len(element) which adds the length of the current list element to a running count count, sequence as the list of lists, and the initial count initial as 0.


how-to-get-the-size-of-a-list-of-lists-in-python