[Tutor] Dividing a float derived from a string

Alan Gauld alan.gauld at btinternet.com
Fri Nov 21 15:05:34 CET 2014


On 21/11/14 13:19, Stephanie Morrow wrote:
>
> try:
>     print float(input) * 12
> except: TypeError, ValueError:
>     print False
>
> The "try" is coming up as red.  Any idea why?

Sorry, I left the colon in after the else.
I think that's what's confusing it...
It should read:

except TypeError, ValueError:

Apologies,
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my phopto-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list