The problem is, if I define a function in python with 3 parameters and then I input only 2 parameters, I will get an error.
Can I define the function so if there is one parameter missing (user has given 2 inputs instead of 3), it will use a default value for that missing parameter such as 0
?
def sum(a, b, c):
return a+b+c
If I use:
add = sum(1, 2)
print(add)
It will give me an error. Now I want to define the function so it will add the missing value as 0
, but if I give all the 3 values, it will not use 0
as a default value.