gpt4 book ai didi

python - 我不断得到 “IndentationError: expected an indented block”

转载 作者:行者123 更新时间:2023-12-02 10:55:49 26 4
gpt4 key购买 nike

我的程序很简单,我打算制作一个控制台应用程序,在其中可以通过乌龟通过“left_star”,“left_circle” ext之类的命令使用Turtle绘制一些艺术品。当我尝试实现更新时,由于某种原因它会导致缩进错误。您能帮我解决这个问题吗?

import turtle
import random
turtle.color('green', 'red')
turtle.begin_fill()
print(" ")
print("right_star: makes a right star. ")
print(" ")
print("left_star: makes a star on the left. ")
print(" ")
print("right_circle: makes a circle on the right. ")
print(" ")
print("left_circle: makes a circle on the left side")
print(" ")
_input = input("What shape do you want to make? type 'help' if you want help: ")


turtle.Turtle()
print(turtle.pos())
if _input == "left_star":
i = 0
while i != 10:
turtle.forward(200)
turtle.left(200)
i += 1
if i > 9:
#_input2 = input("What shape do you want to make? type 'help' if you want help: ")
elif _input=="right_circle":
while True:
turtle.forward(70)
turtle.right(70)
_input2 = input("What shape do you want to make? type 'help' if you want help: ")
else _input == "right_star":
while True:
turtle.right(200)
turtle.forward(200)
while True:
_input2 = input("What shape do you want to make? type 'help' if you want help: ")
elif _input == "left_circle":
while True:
turtle.left(70)
turtle.forward(70)
elif _input == "help":
print("right_star: makes a right star. ")
print("left_star: makes a star on the left. ")
print("right_circle: makes a circle on the right. ")
print("left_circle: makes a circle on the left side")
print("PLEASE RESTART THE APPLICATION!'python opt.py'")

最佳答案

您的elif _input=="right_circle":和所有连续的elifif _input == "left_star":不对齐。删除elif前面不必要的空格。

关于python - 我不断得到 “IndentationError: expected an indented block”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64362056/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com