In python TypeError: def_function() missing 2 required positional arguments: ‘name’ and ‘location’ we face this error message when we miss mentioning arguments in our created function then the function shows this error message. while the function is expecting at least 2 arguments like name or any other and we do not specifically mention or type then this happed, For more clarification see the below example.
Wrong Code
def def_function(name, location):
print(f"hello {name} and your are from {location}")
name = input("What is your name:")
location = input("What is your lacation:")
def_function()
Error Massage
What is your name:Amol
What is your lacation:Pa
Traceback (most recent call last):
File "/home/kali/python/webproject/error/main.py", line 6, in <module>
def_function()
TypeError: def_function() missing 2 required positional arguments: 'name' and 'location'
Wrong code line
def_function()
Correct code line
def_function(name, location)
- Wrong action: def_function()
- Correct action: def_function(name, location)
Entire Correct Code line
def def_function(name, location):
print(f"hello {name} and your are from {location}!")
name = input("What is your name:")
location = input("What is your lacation:")
def_function(name, location)
What is missing 2 required positional arguments:?
when we are trying to call a function called or our created new function like def_function() and pass it no arguments, while the function is expecting at least 2 arguments like name and location we need to mention or type if we do not type we face this issue.
How to fix missing 2 required positional arguments:?
If you want to fix this error then we need to enter expecting at 2 arguments in my case Wrong action: def_function() and correct action: def_function(name, location). For more clarification see the above example.
For more information Visit YouTube Channel.

