Jul-26-2017, 01:22 AM
my question here
In my book, "Teach Your Kids To Code" by Bryson Payne, I'm trying some sample code in the book that's supposed to ask the user to input his/her name and make it spiral on the screen in 4 different colors. I would paste a sample picture of what it's supposed to look like, but every time I try to insert an image into this post, it just says that an unknown error occurs.
For those of you are good enough to not need the image, here is my code:
Traceback (most recent call last):
File "D:/Python/Python36-32/SamsPrograms/SpiralMyName.py", line 13, in <module>
t.pencolor(colors[x%4])#rotate through the four colors
AttributeError: 'dict' object has no attribute 'pencolor'
In my book, "Teach Your Kids To Code" by Bryson Payne, I'm trying some sample code in the book that's supposed to ask the user to input his/her name and make it spiral on the screen in 4 different colors. I would paste a sample picture of what it's supposed to look like, but every time I try to insert an image into this post, it just says that an unknown error occurs.
For those of you are good enough to not need the image, here is my code:
#SpiralMyName.py - prints a colorful spiral of the user's name import turtle t = turtle.pen() turtle.bgcolor("black") colors = ["red", "yellow", "blue", "green"] #ask the user's name using turtle's textinput pop-up window yourName = turtle.textinput("Enter your name", "What is your name?") #draw a spiral of the name on the screen written 100 times: for x in range(100): t.pencolor(colors[x%4])#rotate through the four colors t.penup()#don't draw the regular spiral lines t.forward(x*4)#just move the turtle on the screen t.pendown()#write the inputted name, bigger each time t.write(yourName, font = ("Arial", int( (x + 4) / 4), "bold")) t.left(92)#turn left, just as in our other spiralsAnd the error (NOT the unknown image error, but the error from my code in Python Shell) is:
Traceback (most recent call last):
File "D:/Python/Python36-32/SamsPrograms/SpiralMyName.py", line 13, in <module>
t.pencolor(colors[x%4])#rotate through the four colors
AttributeError: 'dict' object has no attribute 'pencolor'