1# Basic syntax:
2# Using list comprehension:
3sum([len(elem) for elem in list_of_lists])
4
5# Example usage:
6# Say you want to count the number of elements in a nested list like:
7nested_list = [ [1, 2, 3, 45, 6, 7],
8 [22, 33, 44, 55],
9 [11, 13, 14, 15] ]
10
11sum([len(elem) for elem in nested_list])
12--> 14
1>>> mylist = [1,2,3] #list
2>>> len(mylist)
33
4>>> word = 'hello' # string
5>>> len(word)
65
7>>> vals = {'a':1,'b':2} #dictionary
8>>> len(vals)
92
10>>> tup = (4,5,6) # tuple
11>>> len(tup)
123
1# List of strings
2listOfElems = ['Hello', 'Ok', 'is', 'Ok', 'test', 'this', 'is', 'a', 'test']
3len(s)