Python 允许用户创建检查表的程序
这是我到目前为止的编码Python 允许用户创建检查表的程序,python,Python,这是我到目前为止的编码 numofthings=int(input("How many things do you need to pack? ")) numoftasks=int(input("How many tasks do you need to complete to prepare? ")) checklist1=[] end=' ' while end.lower()!='end': item=input("Please enter the things you need
numofthings=int(input("How many things do you need to pack? "))
numoftasks=int(input("How many tasks do you need to complete to prepare? "))
checklist1=[]
end=' '
while end.lower()!='end':
item=input("Please enter the things you need to pack and type 'End' when you're done: ")
checklist1.append(item)
end=item
checklist2=[]
end=' '
while end.lower()!='end':
task=input("What tasks do you have to complete and type 'End' when you're done ")
checklist2.append(task)
end=task
print(checklist1)
print(checklist2)
如何将它们列出的项目保存到数组/列表中?
还有,我怎样才能让他们只列出他们说要打包的物品的数量
我两周前才开始编写代码,如果这是显而易见的,那么很抱歉我忽略了它
如何将它们列出的项目保存到数组/列表中
你已经做得很好了:这就是你得到的
checklist.append(item)
如果您在循环中插入一条简单的报告语句,您将在运行过程中看到:
checklist.append(item)
print(checklist)
在你上交程序之前,对那一行进行注释
不过,我怀疑您需要两份单独的检查表:一份用于包装和任务
我怎样才能让他们只列出
他们说他们必须打包
决定你打算如何决定何时你有足够的钱。当前代码查找触发器值end。如果您知道在进入循环之前必须迭代多少次,请使用for循环:
这会让你动起来吗?你的问题是什么?是不是有些东西没有按照你的预期工作?
for i in range(num_of_things):