user12447087
user12447087

Reputation:

I have this error : raise Teminator turtle.Terminator

Other people asked this question but it didn't help me. I wrote this code:

import turtle
import time

s = turtle.Screen()
t = turtle.Turtle()

t.pd()
t.pensize(3)
t.speed(10)
t.circle(100)

time.sleep(2)
turtle.bye()

fq = str(input("What shape is it? - "))
fq = fq.lower()
while fq != "circle":
    print("It's not the right shape")
    fq = str(input("What shape is it? - "))
    fq = fq.lower()
print("Good Job!")

s = turtle.Screen()
h = turtle.Turtle()

t.pd()
t.pensize(3)
t.speed(10)

t.goto(50, 0)
t.goto(50, 50)
t.goto(0, 50)
t.goto(0, 0)

time.sleep(2)
s.bye()

sq = str(input("What shape is it? - "))
sq = sq.lower()
while sq != "square":
    print("It's not the right shape")
    sq = str(input("What shape is it? - "))
    sq = sq.lower()
print("Good Job!")

and I get this problem when I get to the second turtle:

Traceback (most recent call last):
  File "C:/Users/סער 07.סער/Desktop/Python/Shapes.py", line 24, in <module>
    h = turtle.Turtle()
  File "C:\Users\סער 07.סער\AppData\Local\Programs\Python\Python38-32\lib\turtle.py", line 3813, in __init__
    RawTurtle.__init__(self, Turtle._screen,
  File "C:\Users\סער 07.סער\AppData\Local\Programs\Python\Python38-32\lib\turtle.py", line 2557, in __init__
    self._update()
  File "C:\Users\סער 07.סער\AppData\Local\Programs\Python\Python38-32\lib\turtle.py", line 2660, in _update
    self._update_data()
  File "C:\Users\סער 07.סער\AppData\Local\Programs\Python\Python38-32\lib\turtle.py", line 2646, in _update_data
    self.screen._incrementudc()
  File "C:\Users\סער 07.סער\AppData\Local\Programs\Python\Python38-32\lib\turtle.py", line 1292, in _incrementudc
    raise Terminator
turtle.Terminator

Why do I have this kind of problem? The first turtle is fine without problems but when it gets to the second, I get the above error.

Upvotes: 0

Views: 1943

Answers (1)

cdlane
cdlane

Reputation: 41872

You continue to use turtle after you twice terminate turtle with bye():

turtle.bye()
s.bye()

What did you expect to happen? To setup for the next question, you can use commands like screen.reset(), screen.clear(), turtle.reset(), or simply turtle.clear():

from turtle import Turtle

turtle = Turtle()
turtle.hideturtle()
turtle.speed('fastest')
turtle.pensize(3)

turtle.penup()
turtle.sety(-100)  # center circle on screen
turtle.pendown()
turtle.circle(100)

fq = input("What shape is this? - ").lower()

while fq != 'circle':
    print("That's not the right shape.")
    fq = input("What shape is this? - ").lower()

print("Good Job!")

turtle.clear()

turtle.penup()
turtle.goto(-25, -25)  # center square on screen
turtle.pendown()

for _ in range(4):
    turtle.forward(50)
    turtle.left(90)

sq = input("What shape is it? - ").lower()

while sq != 'square':
    print("That's not the right shape.")
    sq = input("What shape is it? - ").lower()

print("Good Job!")

Upvotes: 1

Related Questions