How to get the size of a list in Python?

PythonServer Side ProgrammingProgramming

Object of any Python sequence data type including list uses a built-in function len() which returns its size i.e. number of elements in it.

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

Built-in list class has a special method called __len__() which also returns size of list.

>>> L1=[1,2,3]
>>> L1.__len__()
3


raja
Published on 06-Feb-2018 11:39:37
Advertisements