How to Call a Multiparameter Function in Python


In this example, we will learn how to call a multiparameter function in Python.

Source Code

def my_function(num1, num2):
    print(num1 + num2)

# A function must be called with the correct number of arguments.
my_function(1, 6)

# If you try to call the function with the Incorrect number of arguments, you will get an error.
my_function(3)

Output:

7
Traceback (most recent call last):
  File "demo.py", line 8, in 
    my_function(3)
TypeError: my_function() missing 1 required positional argument: 'num2'
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments