How can I get the number of elements of a list?
Ex-
items = [] items.append("one") items.append("two") items.append("three")
@Shubham,To get the number of elements in the list you can use the len() function :
items = []items.append("one")items.append("two")items.append("three")len(items) Output- 3
items = []
items.append("one")
items.append("two")
items.append("three")
len(items)
Output- 3
You can use the len() function to count the elements in the list:-
>>> someList=[]>>> print len(someList)0
>>> someList=[]
>>> print len(someList)
0
You can use the following video tutorials to clear all your doubts:-