TAGS :Viewed: 5 - Published at: a few seconds ago

[ How do I find out how many objects are in a list ]

basically what the title says. I want to be able to find out how many objects a list contains. Maybe my Google-fu is failing me or my terminology is wrong.

Answer 1


len(s)

Return the length (the number of items) of an object. The argument may be a sequence (string, tuple or list) or a mapping (dictionary).

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

Answer 2


Check out the len built-in function:

len(someList)

http://docs.python.org/library/functions.html#len

Answer 3


 a = ['1', '2', '3']
 print len(a)

This wiil print:

3