Simple question, how do you tell how many items in a list?
ki4yjl at gmail.com
Fri Jul 11 21:25:45 CEST 2008
On Jul 11, 2:53 pm, Terry Reedy <tjre... at udel.edu> 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.
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.
Now, if we wanted a particular entry, we would do this:
(Remember, when calling something in a list we count zero.)
Hope this helped.
More information about the Python-list