我想创建一个提示输入的程序,并根据此输入提供定制的回复。
代码是,它完美地工作,除了它根本不循环。 (在CMD或Powershell中运行脚本后,它终止并终止。)
我希望程序在每次运行后返回到输入提示符。我想我需要返回函数,但我不知道给出什么样的参数。
此外,ValueError参数有点无意义,存在问题。
Name = input ("What is your name ? ").strip().lower()
while True:
try:
if Name in ("A"):
print("message for A")
break
else:
if Name in ("N"):
print("message for N")
break
except ValueError:
print ("Sorry, my only purpose is to talk to N and A")
else:
print("dammit")
break