I am having trouble with running this code. I am trying to run an instance of turtle, successfully close it, and start a new instance of the turtle. I am able to complete the first iteration but I get a terminator exception raised: Exception has occurred: Terminator exception: no description
at self.turt = Turtle()
, when I debug the program.
I know self.screen.exitonclick()
disposes the turtle and screen, but I thought I was creating a new instance of turtle and screen when I would call the class in Call_Turtle_Looping()
below.
import numpy as np
from turtle import Turtle,Screen
class Turtle_Looping():
def __init__(self):
self.turt = Turtle()
self.screen = Screen()
self.angles = [20,45,65,80,90,95]
self.colors = ["red","blue","red","black","red","blue"]
def Basic_Move(self):
for i in range(len(self.angles)):
self.screen.tracer(0)
self.turt.pendown()
self.turt.color(self.colors[i])
self.turt.right(self.angles[i])
self.turt.forward(150)
self.turt.penup()
self.screen.update()
self.screen.exitonclick()
def Call_Turtle_Looping():
for i in range(4):
print(f"we are on run #{i}")
inst = Turtle_Looping()
inst.Basic_Move()
Call_Turtle_Looping()