[Tutor] I need help solving this

Alan Gauld alan.gauld at yahoo.co.uk
Wed Jun 10 05:44:55 EDT 2020


On 10/06/2020 03:46, Adam Eyring wrote:
> If you set up your if statements correctly to respond to the user input,
> you should only get one output. e.g.
> i = input("(B)lue, (G)reen, (Y)ellow?")
> if i == "B":
>     draw blue circle
> elif i == "G":
>     draw green circle
> else:
>     draw yellow circle
> 
Or even better just set the parameters in the if statement
then draw the circle once at the end. That way you can
guarantee you only ever draw one circle even if you
somehow set more than one group of values..

col = input("(B)lue, (G)reen, (Y)ellow?")
if col == "B":
     set blue values
elif col == "G":
     set green values
else:
     set yellow values

draw_circle(values)

-- 
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 photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list