'Python, Turtle - File "<string>", line 12, in forward turtle.Terminator
Hi there I have written a program in Python 3.10 and i am using the Library Tuple
I have 4 different classes: Polygon, Square(Polygon) - Child Class, Shape and Point.
The problems that I have are:
- 1 want to plot them on different graphs
I have some more code in between drawing the graphs and the thing is:
The problem is when I close the first window to execute the remaining code it pops the error: Python, Turtle - File "", line 12, in forward turtle.Terminator
class Polygon: def __init__(self, sides, name, side_length=100, colour="black", line_thickness=5, x_pos=90, y_pos = 90): self.sides = sides self.name = name self.side_length = side_length self.colour = colour self.line_thickness = line_thickness self.x_pos = x_pos self.y_pos = y_pos def draw(self): turtle.penup() turtle.setpos(self.x_pos, self.y_pos) for i in range(self.sides): turtle.pendown() turtle.color(self.colour) turtle.pensize(self.line_thickness) turtle.forward(self.side_length) turtle.right(180 - self.individual_angle) class Square(Polygon): def __init__(self, side_length=100, colour="black", line_thickness=5, x_pos=90, y_pos=90): super().__init__(4, "Square", side_length, colour, line_thickness, x_pos, y_pos) def draw(self): turtle.begin_fill() super().draw() turtle.end_fill() square = Polygon(4, "Square", 100, line_thickness=10, x_pos=-300, y_pos=-20) pentagon = Polygon(5, "Pentagon", colour="red", x_pos=-50, y_pos=-220) hexagon = Polygon(6, "Hexagon", 150, "orange", x_pos=180, y_pos=320) square.draw() hexagon.draw() pentagon.draw() square2 = Square(colour="red", side_length=250, x_pos=92, y_pos=-100) square2.draw() turtle.done()
No, my code does not have any indentation errors.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
