How to find an item/items in a list?
Bjorn Pettersen
BPettersen at NAREX.com
Tue May 6 12:29:13 EDT 2003
> From: Alex Martelli [mailto:aleax at aleax.it]
>
> <posted & mailed>
>
> Bjorn Pettersen wrote:
> ...
>
> > def after(lst, item):
> > try:
> > # throws ValueError when not found,
> > # TypeError if lst is a string and item is not
> > index = lst.index(item)
> > # throws IndexError when out-of-range
>
> *blink* -- can you please give an example...???
>
> > return lst[index+1:]
Sure,
1. 1:00 am
2. intially forgot the ':'
3. dutifully commented the behavior
(I really should try to go to bed sometimes...)
Sorry,
-- bjorn
More information about the Python-list
mailing list