Click here to Skip to main content
15,885,182 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
def add(num1, num2, *args):
    total = num1 + num2
    for arg_item in args:
        total += arg_item
    return total
print(add(6, 2))
print(add(6, 2, 10, 1, 4))
print(add(6, 2, 10, 1, 4, 100, 50, 1))
print(add(6))    # what is happening here?


What I have tried:

I have done this but, not able to figure it out.
Posted
Updated 7-Nov-21 7:32am
v3
Comments
Tony Hill 7-Nov-21 14:12pm    
Why did you remove the question you asked, don't you think that leaving the question there might help somebody else and adds context to the solution.
WillDavid 7-Nov-21 17:33pm    
Sorry sir, but i had too, i am planning to delete my current account and to create a new one so i can follow the rules i have known within these 2 or 3 days.

Thank you:
Will David

1 solution

+You get an error because the function requires at least two parameters, num1 and num2
Since you provide only one, the system can't call the function and raises an error instead.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900