beginner's python help

Chris Rebert clp2 at rebertia.com
Sun Sep 6 09:50:37 CEST 2009


On Sun, Sep 6, 2009 at 12:46 AM, hrishy<hrishys at yahoo.co.uk> wrote:
> Hi Chris
>
> What if i want to log that bad data and continue processing is there a way to do that ?

Tighten the area included in the try...except:

sum = 0
for item in readData:
    try:
        sum += int(item)
    except ValueError:
        print "Oops!  That was no valid number. Instead it was:", item

Also, in the future, please avoid top-posting
(http://en.wikipedia.org/wiki/Top-post).

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list