beginner's python help
Chris Rebert
clp2 at rebertia.com
Sun Sep 6 03:58:42 EDT 2009
On Sun, Sep 6, 2009 at 12:54 AM, hrishy<hrishys at yahoo.co.uk> wrote:
> Hi
>
> sum = 0
> for item in readData:
> try:
> sum += int(item)
> except ValueError:
> print "Oops! That was no valid number. Instead it was:", item
>
> So you mean to say this would ignore the bad data and continue processing ?
Yes. A new "try" happens every loop iteration since the "try" is
within the loop body.
Cheers,
Chris
--
http://blog.rebertia.com
More information about the Python-list
mailing list