swim_length =int(input("Please enter a swim length: "))
while swim_length < 0:
print("The length has to be a positive number")
swim_length=int(input("Please enter a positive number: ")
您好,有人可以帮我吗,我确定我犯了一个简单的错误,但我不知道确切的位置。
答案 0 :(得分:2)
您必须在while循环中添加缩进,并在最后一行的末尾添加括号:
swim_length =int(input("Please enter a swim length: "))
while swim_length < 0:
print("The length has to be a positive number")
swim_length=int(input("Please enter a positive number: "))
答案 1 :(得分:0)
在最后一行的第一行中,您错过了结尾)
swim_length=int(input("Please enter a positive number: "))
while循环的主体也需要缩进
while swim_length < 0:
print("The length has to be a positive number")
swim_length=int(input("Please enter a positive number: ")