4
Please help me that, what's happening in line 9
source link: https://www.codeproject.com/Questions/5317035/Please-help-me-that-whats-happening-in-line-9
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Copy Code
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.
+You get an error because the function requires at least two parameters,
Since you provide only one, the system can't call the function and raises an error instead.
num1
and num2
Since you provide only one, the system can't call the function and raises an error instead.
Add your solution here
Preview
Existing Members
Sign in to your account
...or Join us
Download, Vote, Comment, Publish.
Your Email Password
Your Email Optional Password
StrengthToo short
I have read and agree to the Terms of Service and Privacy Policy
Please subscribe me to the CodeProject newsletters
Please subscribe me to the CodeProject newsletters
When answering a question please:
- Read the question carefully.
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
- If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
- Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK