I want to write a program that changes the turtle image in order each time I press the 'n' key.
It should first start with the 'classic' shape, and every time the 'n' key is pressed, change the shape to 'circle', 'arrow', 'turtle' and then loop back to 'classic'.
import turtle
canvas = turtle . Screen ()
t = turtle . Turtle ()
def changeTurtle () :
for n in range (1, 5) :
if n == 1 :
t . shape ('circle')
elif n == 2 :
t . shape ('arrow')
elif n == 3 :
t . shape ('turtle')
elif n == 4 :
t . shape ('classic')
t . shape ('classic') # first turtle 'classic' shape
canvas . onkey (changeTurtle, 'n') # press 'n'key
canvas . listen ()
turtle . mainloop ()
It should have changed once when I pressed the 'n' key. The problem is, it is changing too quickly.