Shi Mu <[EMAIL PROTECTED]> wrote: ... > If we do not know when the error will happen during the calculation > but still want to continue till end, what should I do? > for example: > > def test(a,b,c): > return a/(b-c) > q=[1,1,2,2,4,6,9,0] > for i in range(len(q)): > print test(q[i],q[i+1],q[i+2])
put the try/except around the print statement (you'll also need to decide whether you also want to catch the IndexError you'll get towards the end of the sequence, of course;-). Alex -- http://mail.python.org/mailman/listinfo/python-list