DEV Community

Discussion on: What is a side-effect of a function in Python?

Collapse
 
bieniekalexander profile image
Alexander Bieniek

There's an error in your What are arguments? section. you have the following definition:

def sum(num1, num2):
    return num1 + num2
Enter fullscreen mode Exit fullscreen mode

You then try to use the sum function you defined:

val1 = 10
val2 = 20
ans = sum(val1 + val2)
Enter fullscreen mode Exit fullscreen mode

However, you defined sum to be a function that takes exactly two arguments, and you called it as a function that takes exactly one argument, so that call to sum won't work:

>>> sum(val1+val2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: sum() missing 1 required positional argument: 'num2'
Enter fullscreen mode Exit fullscreen mode

So, you'll need to call it as: sum(val1, val2)

Collapse
 
dev0928 profile image
dev0928

Thanks for pointing out the issue! Now it is fixed.