【发布时间】:2020-06-12 19:03:59
【问题描述】:
我想知道如何从用户输入中获取与列表相关的操作。这将是我的“解决方案”,但它不起作用,只是将用户的输入返回给我。
oldList = ['1', '2']
newList = input('Which number should be included in the List?')
if newList == 1:
oldList.append(1)
elif newList == 2:
oldList.append(2)
print(oldList)
提前致谢!
【问题讨论】: