Reputation: 3
I'm in an Intro CSci course and I honestly have no background in coding at all, one of our assignments is to have the user input a Hexadecimal code that changes the color of the turtle, but I'm not sure how to do that.
usernumber = input("Please enter a 6-digit Hexadecimal number: ")
import turtle
suga = turtle.Turtle()
suga.shape('turtle')
suga.color("#usernumber")
for i in range(4):
suga.left(90)
suga.forward(100)
suga.stamp()
This is what I have, everything works other than the turtle color. The assignment says I have to include the hashtag for the Hexadeci, but I don't know how to input the usernumber as the color. It never works.
Literally ignore if I made stupid mistakes, I genuinely know nothing, nada, about code so. And yes my turtle is named after a BTS member.
Upvotes: 0
Views: 2213
Reputation: 323
Try changing your line:
suga.color("#usernumber")
To
suga.color(usernumber)
Or if the user isn't expected to add the #
character themselves, then you could do:
suga.color('#' + usernumber)
"#usernumber"
is a literal string. usernumber
is the variable containing the input from the user from your call to input()
on the first line.
Upvotes: 1