为什么我的 Python 3 代码不起作用?

阿纳夫

我必须为我的总结性项目编写一个文本编辑器(从 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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

为什么我的reverse()方法在python 3中不起作用?

为什么我的日志记录在Python 3中不起作用?

为什么python3中的round()内置函数对我不起作用?

为什么我的网页抓取工具不起作用?Python3 - 请求,BeautifulSoup

为什么相对导入在Python 3中不起作用?

为什么遵循Couchbase异步Python代码不起作用?

简单的 python 和 vtk 代码不起作用。为什么?

这个简单的python代码,为什么不起作用?

为什么此python代码不起作用?

为什么这个 Python“循环代码”不起作用?

为什么下面的python代码不起作用?

为什么 python 导入在 VS 代码中不起作用?

为什么条件“ else”在我的python代码中不起作用

Python Crashcourse-10-4-为什么我的代码版本不起作用?

为什么 python list append 在我的代码中不起作用?

为什么我的状态代码在PyCharm(Python 3.8)上不起作用

替换或转义& 在我的Python代码中不起作用。为什么?

使用 Flask 框架的 Python 代码不起作用,我不知道为什么

为什么我的d3.tip不起作用?

为什么我的 Sublime Text 3 包不起作用?

为什么我的代码不起作用?

我正在尝试学习 python 但我的代码不起作用,我不知道为什么

使用 Python 3.xx 代码的 Hackerrank 不起作用

为什么我的Python PIL导入不起作用?

为什么我的“else”语句在 python 中不起作用?

为什么replace()在我的Python函数中不起作用?

为什么我的 IF 语句在 python 上不起作用?

Python 和 BeautifulSoup:为什么我的 if 条件不起作用

为什么我的for循环不起作用?(Python)