Python Script to get Info from Site not working

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Mar 10 20:38:09 EST 2010


En Wed, 10 Mar 2010 20:06:41 -0300, Jimbo <nilly16 at yahoo.com> escribió:

> I found a semi Python & internet tutorial here if anyone else would
> like it http://www.upriss.org.uk/python/session6.html
>
> My script is meant to find which radio button is selected & tell me
> that. But it just keeps saying "No Drink Selected!"

Are you sure? From the code you posted, the message should read "You need  
to select a drink!", not that one.

> if drink == "tea":
>     print("You requested tea.")
> elif drink == "coffee":
>     print("You requested coffee.")
> elif drink == "hot chocolate":
>     print ("You requested hot chocolate.")
> else:
>     print ("You need to select a drink!")

Replace the last line with something like this, to see what you are  
getting exactly:

        print("Sorry, no %r (%r) available." % (
           drink,
           cgi.escape(repr(type(drink)))))

BTW, which Python version are you using? The tutorial you linked to is  
aimed at Python 2.x, but your print syntax suggests you're using Python 3.x

-- 
Gabriel Genellina




More information about the Python-list mailing list