我写了一些代码并且它工作正常(从我可以看到的无论如何)直到我到达“其他”部分,我真的只想设置一个简单的循环,但我不知道如何。错误是“预期的语句,找到 Py:ELSE_KEYWORD 预期的语句,找到 Py:COLON”
name = input("Hello, what is your name? ")
restart = input ("Do you want to chat 'y' (type 'y' for yes) or 'n'")
while restart == "y":
print("Hello " + name)
feeling = input("How are you today? ")
print("I'm feeling good!")
else:
print("Sorry, the restart")
else: print("goodbye")
我只是想设置我的循环,然后我将完成我的代码。
三件事:
这是您的代码的清理版本:
name = input("Hello, what is your name? ")
restart = input ("Do you want to chat 'y' (type 'y' for yes) or 'n'")
while restart == "y":
print("Hello " + name)
feeling = input("How are you today?")
print("I'm feeling " + feeling)
restart = input ("Do you want to chat 'y' (type 'y' for yes) or 'n'")
print("Goodbye")
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句