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

PythonServer Side ProgrammingProgramming

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
raja
Published on 09-Jan-2018 09:09:33
Advertisements