list.index crashes when the element is not found

Nick J Chackowsky mediocre_person at hotmail.com
Fri May 2 14:58:29 EDT 2008


TkNeo wrote:
> WHAT ?
> 
> This is crazy

Crazy like a fox?

a = [1, 2, 3]
try:
     a.index(99)
except:
     a.append(99)
finally:
     print a.index(99)

MY question: which exception should I actually be catching there?
** Posted from http://www.teranews.com **



More information about the Python-list mailing list