Simple question, how do you tell how many items in a list?

WDC ki4yjl at
Fri Jul 11 21:25:45 CEST 2008

On Jul 11, 2:53 pm, Terry Reedy <tjre... at> wrote:
> Alex Bryan wrote:
> > I am just wondering how you get an integer value for how many items
> > there are in a list, preferably w/o a for loop.
> Read the library reference sections on built-in functions and classes.

Quite simple.

If I understand you correctly, you have a list like this:

>>> list = ['a', 'b', 'c', 'd']

As you can see, the list has 4 entries.

The len() function also says that we have 4 entries.

>>> len(list)

Now, if we wanted a particular entry, we would do this:

>>> list[0]

(Remember, when calling something in a list we count zero.)

>>> list[3]

Hope this helped.


More information about the Python-list mailing list