0
Help!
Hello can someone explain to me what is wrong with my code? This is the question: Given a function that takes 2 arguments and returns their sum. But we get an error when we want to sum more than 2 numbers. Change the function and complete the code so that the function sums as many numbers as are input. This my code: #change the function def adder(x, y,*args): print(x+y) sum(args) adder(2, 3) adder(2, 3, 4) adder(1, 2, 3, 4, 5)
4 Réponses
+ 1
Hi! For better help to you, please, show us your code attempt! Thx!
0
distinguish between where is the task code and where exactly is your code?
0
Yaroslav Vernigora sorry mb. This was the given code: #change the function
def adder(x, y):
print(x+y)
adder(2, 3)
adder(2, 3, 4)
adder(1, 2, 3, 4, 5)
0
Give list as function parameter instead of variables and output sum of elements of the list