我必须为我的总结性项目编写一个文本编辑器(从 Adventures 中分拆到 Zork)游戏。
这是我对第一个区域的决定。
second = True
while second:
firstLog = input(">")
这就是我遇到问题的地方,因为当我输入“Inside”或“In”时,脚本会终止。
if firstLog = "Inside" or "In" or "Space Ship":
print("There is a small " color.Bold + "console " + color.End + "in front of you.")
print("You can " + color.Bold + "input " + color.End + "or" + color.Bold + "Exit" + color.End)
second = False
此外,如果我输入任何其他内容,它也会终止,而不是打印此内容并重新启动循环。
else:
"Not valid."
second = True
几样东西。最后你缺少一个打印语句。
else:
print("Not valid.")
if firstLog 应该再次说明变量比较。
if firstLog == "Inside" or firstLog == "In" or firstLog == "Space Ship":
更好的是,你可以做这样的事情:
if firstLog.lower() in ["inside", "in", "space ship"]:
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句