list index()

zzbbaadd at zzbbaadd at
Thu Aug 30 18:41:00 CEST 2007

On Aug 30, 12:09 am, Ben Finney <bignose+hates-s... at>
> zzbba... at writes:
> > What's with the index() function of lists throwing an exception on not
> > found?
> It's letting you know that the item isn't in the list. There's no
> sensible return value from an "index" function in that condition.

for str:

find(  	sub[, start[, end]])
    Return the lowest index in the string where substring sub is
found, such that sub is contained in the range [start, end]. Optional
arguments start and end are interpreted as in slice notation. Return
-1 if sub is not found.

-1 is used in other languages as well.

More information about the Python-list mailing list