python - How can I make the value of a user's input into a variable with a usable value? -


from turtle import*  branch_width=4 grass_color=input("would grass snowy, dead, or healthy? ") sky_color=input("would morning, afternoon, or evening? ")  morning="cadetblue" afternoon="cornflowerblue" evening="royalblue" snowy="snow" dead="wheat" healthy="darkgreen" 

every time try use input color(sky_color), user's input not translated morning="cadetblue", etc, returns error. how fix this? need make user type in color?

you have confused variable names , character strings. set variable called morning string "cadetblue". has nothing input string "morning". you have set explicitly.

a dictionary here:

interpret_color = {     "morning": "cadetblue",     "afternoon": "cornflowerblue",     "evening": "royalblue",     "snowy": "snow",     "dead": "wheat",     "healthy": "darkgreen" } 

now can try

color(interpret_color(sky_color)) 

does moving?


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -