嘿,谢谢你抽出时间来帮助我,我来直接说: 这只是一个我开始练习Python技能的小项目,在我的GCSE之前。目前遇到的问题是将数字添加到列表中。我已经解决了程序的所有当前问题,但是我无法解决这个问题。欢迎提供有关此问题/使程序更有效的任何反馈。谢谢。
##code##
name = input("hello user what is your name?")
print("thank you for using our program:",name.title(),)
userchoice = input("which program would you like to use: add numbers,minus
numbers, alphabetical word order?")
#add numbers#
numList = []
addnewnumber = input ("would you like to add a new number?")
while addnewnumber == 'yes':
newnumber = input("what is your number?")
numList.append()
if addnewnumber == 'no':
numListsum = sum(numList)
print (numListsum)
##Console message##
RESTART: C:/Users/SWILS/AppData/Local/Programs/Python/Python36/python
coding/1.0.py
hello user what is your name?sean
thank you for using our program: Sean
which program would you like to use: add numbers,minus numbers, alphabetical
word order?add numbers
would you like to add a new number?yes
what is your number?6
Traceback (most recent call last):
File "C:/Users/SWILS/AppData/Local/Programs/Python/Python36/python
coding/1.0.py", line 11, in <module>
numList.append()
TypeError: append() takes exactly one argument (0 given)
numList.append()
这一行代码的目的是什么? - Ry-numList.append()
: 添加 什么? - kindall.append
接受一个"参数",这个参数是你想要追加的内容。也许你想要执行numList.append(newNum)
? - Izaak van Dongen