I want to draw a box that will appear in a random place in the window. But it gives an error in line 33: name 'draw' is not defined . Tell me please, what am I doing wrong?
import turtle import time import random class Rectangle: def __init__(self, x, y): self.x = x self.y = y def draw(self): self.color('black') self.penup() self.setpos(x, y) self.pendown() self.goto(x + 50, y) self.goto(x + 50, y + 50) self.goto(x, y + 50) self.goto(x, y) rect1 = Rectangle(random.randint(-200, 200), random.randint(-200, 200)) turtle.tracer(0, 0) turtle.hideturtle() rect1 = turtle.Turtle() rect1.hideturtle() while True: time.sleep(0.5) rect1.clear() draw(rect1) #ошибка turtle.update()
rect1.draw()- slippykrect1 = Rectangle, then the redefinition ofrect1 = turtle.Turtle(), anddraw(rect1), this function is not described anywhere, there is only a class methodRectangle().draw()- slippyk