1

I'm trying to make a snake game and when I write the codes to create the window, I get an image like this:

enter image description here

and the codes I wrote:

import turtle

window = turtle.Screen()
window.title("Snake Game")
window.bgcolor('lightgreen')
window.setup(width=600 , height=600)
window.tracer(0) 

head = turtle.Turtle()
head.speed(0)
head.color('white')
head.shape('square')
head.penup() 
head.goto(0, 100)
head.direction = 'stop'


while True :
    window.update()



turtle.done

The other problem is when i close the window i get an error like this:

Traceback (most recent call last):
  File "practice.py", line 19, in <module>
    window.update()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/turtle.py", line 1304, in update
    t._update_data()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/turtle.py", line 2647, in _update_data
    self.screen._incrementudc()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/turtle.py", line 1293, in _incrementudc
    raise Terminator
turtle.Terminator

Do you have any solution for this problem?

Caridorc
  • 6,222
  • 2
  • 31
  • 46
Bhrye
  • 11
  • 1
  • 1
    This error occurs when you try to run turtle code after exiting. Avoid `while True:` in turtle scripts. Prefer `ontimer`. Also, `turtle.done` should be `turtle.done()`. – ggorlen Feb 05 '23 at 19:46
  • 1
    Does this answer your question? [Python Turtle.Terminator even after using exitonclick()](https://stackoverflow.com/questions/45534458/python-turtle-terminator-even-after-using-exitonclick) – ggorlen Feb 05 '23 at 19:47

0 Answers0