我一直在 if 语句中收到语法错误,我不确定为什么会收到错误。谁能帮忙?
def draw_square(self, loc, width):
loc = (x, y)
for i in range (3):
width(width)
turtle.forward(60)
turtle.right(90)
turtle.forward(random.randint(10,100))
turtle.right(90)
turtle.forward(60)
turtle.right(90)
turtle.forward(random.randint(10, 100))
if turtle.xcor < or > x:
x = turtle.xcor
elif turtle.ycor < or > y:
y = turtle.ycor
return self.loc, self.width
请您参考如下方法:
认为您的语法在以下方面无效:
if turtle.xcor < or > x:
x = turtle.xcor
elif turtle.ycor < or > y:
y = turtle.ycor
尝试改变它:
if turtle.xcor < x or turtle.xcor > x:
x = turtle.xcor
elif turtle.ycor < y or turtle.ycor > y:
y = turtle.ycor
