What are required arguments of a function in python?

PythonServer Side ProgrammingProgramming

Required arguments are the mandatory arguments of a function. These argument values must be passed in correct number and order during function call. 

If you run the given code you get the following output

Hi 15
Traceback (most recent call last):
  File "requiredarg1.py", line 4, in <module>
TypeError: requiredArg() takes exactly 2 arguments (1 given)


In the output above for the first function call with two required arguments we get the output as Hi 15. But for the second function call with only one argument, we get a TypeError saying the function takes exactly 2 arguments. This shows the importance of required arguments and their mandatory nature

Published on 07-Dec-2017 17:16:21