Why does the argument (2,3,e="+") of the function bring to syntax error? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why does the argument (2,3,e="+") of the function bring to syntax error?

Test program: def ar(q,w,e): if e=="+": return q+w ar(2,3,e="+") #line 4 invalid syntax

28th Jun 2019, 5:33 AM
Valeria Vasylieva
2 Answers
+ 2
Seb TheS Unexpectedly. Thank you!
28th Jun 2019, 1:13 PM
Valeria Vasylieva
+ 1
Argument e="+" does not cause the error. The thing, which I suspect caused the error, is that you didn't follow the indentation rules of Python. When you define a statement, such as function definition, it used colon ":" in end of the line "def ar(q, w, e)", it means, that the code of the following indentation level belongs to the ar function. The if statement also has it's own indentation level. #Valid: def ar(q, w, e): if e == "+": return q + w ar(2, 3, e="+") #Invalid: def ar(q, w, e): if e == "+": return q + w ar(2, 3, e="+")
28th Jun 2019, 7:44 AM
Seb TheS
Seb TheS - avatar