How to get length of a list of lists in Python?


You can employ a nested loop to count number of elements in each sublist of a list

>>> a=[[1, 2, 3], [4, 5, 6]]
>>> c=0
>>> for x in a:
      for y in x:
      c=c+1


>>> c
6

Updated on: 19-Dec-2019

220 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements