任何人都可以理解为什么如果回答不正确,这不会重置?
def loop1:
(print) ("Please Enter Your Name.")
myName = input(:)
(print) ("Hello " +myName)
(print) ("Would You Kindly Confirm If the Hatch Is Open Or Closed O/C")
hacthStatus = input ()
if hacthStatus == ('C'):
loop1()
答案 0 :(得分:1)
您的代码没有缩进,而且您还没有正确定义函数
试试这个
def loop1():
print ("Please Enter Your Name.")
myName = input(":")
print ("Hello " +myName)
print ("Would You Kindly Confirm If the Hatch Is Open Or Closed O/C")
hacthStatus = input ()
if hacthStatus == 'C':
loop1()
loop1()
以上代码相当于
hacthStatus = 'C'
while hacthStatus == 'C':
print ("Please Enter Your Name.")
myName = input(":")
print ("Hello " +myName)
hacthStatus = input ("Would You Kindly Confirm If the Hatch Is Open Or Closed O/C\n")