I am trying to make a Python program run continuously, with turtle graphics displaying the correct answer. While the program works, after every successful run, it will give me a turtle.Terminator error. I.e it will run the first time with an error of turtle.Terminator, then the second time it will run fine with no errors.
I tried using from turtle import Turtle, and changing the variables accordingly, but to no avail. I have also tried to make a function for creating the window, and then calling the result() function, but also to no avail.
import turtle
import random
def result(x, comment):
width = 450
length = 335
turtle.setup(width,length)
turtle.bgcolor("black")
turtle.title("Guess the number")
fonts = ['times new roman', 'americana', 'verdana']
turtle.hideturtle()
turtle.penup()
turtle.goto(0, 40)
turtle.color("green")
turtle.write(x, align = "center", font = (random.choice(fonts),30,
"italic"))
turtle.pendown()
turtle.penup()
turtle.goto(0, -40)
turtle.color("blue")
turtle.write(comment, align = "center", font = (random.choice(fonts),30,
"italic"))
turtle.pendown()
#turtle.done()
p = 'y'
while p == 'y' or p == 'Y':
bot = random.randint(1,1)
p1 = int(input("Please enter a number: "))
if bot == p1:
r = "WINNER"
c = "GREAT JOB"
result(r,c)
if bot != p1:
r = "LOSER"
i = "you're dumb as a rock"
result(r, i)
p = input("do you want to try again: " )
if p == 'y' or p == 'Y':
turtle.clear()
else:
turtle.done()
break