Reputation: 11
I want to ask "Choose your pen colour(red, orange, yellow, green or blue): " and change turtle pen colour according to their choices. And this are my lines so far:
colors = ["red", "orange", "yellow", "green", "blue"]
color = input ("Please choose your color (red, orange, yellow, green, blue): ")
color = choice.colors
turtle.color (color)
system says "choice" is not defined. How do I solve this?
Upvotes: 0
Views: 469
Reputation: 41872
The random.choice()
function is used when you want the computer to randomly choose a color. Since you're letting your user decide, we don't need it:
import turtle
COLORS = ['red', 'orange', 'yellow', 'green', 'blue']
color = input("Please choose your color ({}): ".format(', '.join(COLORS)))
turtle.color(color)
turtle.done()
Upvotes: 1