list.index crashes when the element is not found

Jeff jeffober at gmail.com
Fri May 2 15:49:53 EDT 2008


The generally used idiom for that is:

lst = ['a', 'b', 'c']
if 'a' in lst:
  foo = lst.index('a')



More information about the Python-list mailing list