
- Python 3 Basic Tutorial
- Python 3 - Home
- What is New in Python 3
- Python 3 - Overview
- Python 3 - Environment Setup
- Python 3 - Basic Syntax
- Python 3 - Variable Types
- Python 3 - Basic Operators
- Python 3 - Decision Making
- Python 3 - Loops
- Python 3 - Numbers
- Python 3 - Strings
- Python 3 - Lists
- Python 3 - Tuples
- Python 3 - Dictionary
- Python 3 - Date & Time
- Python 3 - Functions
- Python 3 - Modules
- Python 3 - Files I/O
- Python 3 - Exceptions
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
#!/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)
- Related Articles
- What are required arguments of a function in python?
- Keyword arguments in Python
- Default arguments in Python
- Command Line Arguments in Python
- Variable-length arguments in Python
- Packing and Unpacking Arguments in Python?
- What are default arguments in python?
- Command Line and Variable Arguments in Python?
- How to add command line arguments in Python?
- How to pass arguments by value in Python function?
- How to pass arguments by reference in Python function?
- How to handle invalid arguments with argparse in Python?
- How do we access command line arguments in Python?
- How to pass arguments by reference in a Python function?
- What is the difference between arguments and parameters in Python?

Advertisements