Peter Chappy
Peter Chappy

Reputation: 1179

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.

Upvotes: 0

Views: 3576

Answers (3)

beduin
beduin

Reputation: 8273

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

This wiil print:

3

Upvotes: 0

Jeremy Flores
Jeremy Flores

Reputation: 483

Check out the len built-in function:

len(someList)

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

Upvotes: 0

NullUserException
NullUserException

Reputation: 85488

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

Upvotes: 6

Related Questions