How do we get size of a list in Python?

PythonServer Side ProgrammingProgramming

Python's built in function len() returns number of elements in a sequence including list object.

>>> L1=[1,2,3,4,5]
>>> len(L1)
5

The built-in function len() implements the __len__() method defined for all sequence type classes including list class. It also returns size.

>>> L1.__len__()
5
raja
Published on 15-Feb-2018 08:04:25
Advertisements