Reputation: 53
Hey thank you for taking the time to help me out, I'll cut straight to the point: This is just a small project I've started to practice my Python skills before my GCSE the current issue I'm having is appending a number to a list as I have gone through each part of the program I've managed to resolve all current issues, however, I have been unable to resolve this issue all/any feedback concerning this issue/ making the program more efficient would be appreciated. Thank you.
##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)
Upvotes: 3
Views: 45414
Reputation: 2338
The correct syntax is like this:
numList = []
addnewnumber = input ("would you like to add a new number?")
while addnewnumber == 'yes':
newnumber = input("what is your number?")
numList.append(newnumber)
The problem was that you needed to pass a value to the append
method of numList
, for it to append.
Upvotes: 0
Reputation: 2996
append
functioncode updated to do what you want:
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(newnumber)
addnewnumber = input ("would you like to add a new number?")
numListsum = sum(numList)
print (numListsum)
Upvotes: 0
Reputation: 1415
Your numList.append()
must have a paramter.
So , change to this numList.append(newnumber)
.
Upvotes: 2
Reputation: 168636
The error message means exactly what it says: .append()
expects you to pass one parameter, but you've actually passed no parameters. Try this:
numList.append(newnumber)
Upvotes: 0