• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python Not sure how I can fix my code for a small turtle feeding game (in turtle) :)

Guest88

New Coder
Hi,
I'm having some issues with this section of my code, it has errors in Terminal and the feedback isn't very specific. Thanks!!

Code:
import turtle
import time
variable1=turtle
# turtle object
#img_turtle = Turtle.fish()
#turtle.register_shape('turtle.gif')
#img_turtle.shape('turtle.gif')
speed = 2
def travel():
    turtle.penup()
    turtle.forward(speed)
    variable1.ontimer(travel, 10)
variable1.onkey(lambda: turtle.setheading(90), 'Up')
variable1.onkey(lambda: turtle.setheading(180), 'Left')
variable1.onkey(lambda: turtle.setheading(0), 'Right')
variable1.onkey(lambda: turtle.setheading(270), 'Down')
variable1.listen()
travel()
variable1.mainloop()
 
Top