python - 试图退出程序,得到无限循环(Python)
问题描述
我是一个初学者,试图退出我在 Python 中的第一个程序,但只是得到无限循环。无法理解出了什么问题。
question = input("Please enter your 'to do' list: ")
some_list = []
while True:
if question not in some_list:
some_list.append(question)
question = input("Please enter your 'to do' list: ")
else:
print("\n\nPress enter to exit")
print(some_list)
解决方案
首先,永远不要使用内置函数作为变量。您基本上将数字 4 分配给数字 5:4=5。这是错误的。我在那里修好了。
question = input("Please enter your 'to do' list: ")
something = []
while True:
if question not in something:
something.append(question)
question = input("Please enter your 'to do' list: ")
else:
print("\n\nPress enter to exit")
print(something)
`
推荐阅读
- spss - 箱线图图例
- vue.js - 使两个输入在双向绑定中相互更新
- c# - 有没有办法在页面刷新时防止复杂对象出现空对象错误?
- ruby-on-rails - 具有多个可选关联的 Rails 模型范围
- postgresql - postgres中/dt中的'd'是什么意思
- python-3.x - Python 字典 - 组合字典
- javascript - 如何在本地主机上使用 Shopify 的 App Bridge 进行开发?
- remote-access - Pyro4:从远程 pyro 对象调用远程方法
- reporting-services - 数据驱动订阅无法正常工作
- python - NameError:名称“光标”未定义