I have a generator as follows to do list calculations.

*result = [(ListA[i] - ListB[i-1])/ListA[i] for i in range(len(ListA))]*

The above generator, throws  '*ZeroDivisionError*' exception if ListA[i] =
0.
Is there a way to say 'Don't divide by ListA[i] if its equal to 0 (within
that statement)'.

Sorry if this question sounds too stupid.

TIA
Joe
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to