Computer >> Computer tutorials >  >> Programming >> Python

How to get the size of a list in Python?


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