Counting the number of elements in a list - help.

Bryce C. Mason bmason at rand.org
Tue Apr 16 16:05:44 EDT 2002


Sure was!  Thanks


"Steingrim Dovland" <steingrd at ifi.uio.no> wrote in message
news:m3n0w3fmhf.fsf at localhost.localdomain...
> "Bryce C. Mason" <bmason at rand.org> writes:
>
> > 1) a function which returns the number of elements in a list
> > 2) a function which takes a list and an index and returns a zero when
that
> > list index is out of range.
>
> I think you're looking for len(), a built in function.
>
> >>> x = [1,2,3]
> >>> len(x)
> 3
>
> --
> Here the sea spray give
> I was with her
> We're under the ship so get me over





More information about the Python-list mailing list