Required arguments in Python


Required arguments are the arguments passed to a function in correct positional order. Here, the number of arguments in the function call should match exactly with the function definition.

To call the function printme(), you definitely need to pass one argument, otherwise it gives a syntax error as follows −

Example

 Live Demo

#!/usr/bin/python
# Function definition is here
def printme( str ):
"This prints a passed string into this function"
print str
return;
# Now you can call printme function
printme()

Output

When the above code is executed, it produces the following result −

Traceback (most recent call last):
File "test.py", line 11, in <module>
printme();
TypeError: printme() takes exactly 1 argument (0 given)

Updated on: 30-Jan-2020

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements