In python TypeError: def_function() missing 1 required positional argument: ‘name’ we face this error message when we are trying to call a function called or our created new function like def_function() and passing it no arguments, while the function is expecting at least one argument like name or any other and we do not specifically then we face this issue, For more clarification see the below example.
Wrong Code
def def_function(name):
print(f"hello {name}")
name = input("What is your name:")
def_function()
Error Massage
What is your name:Amol
Traceback (most recent call last):
File "/home/kali/python/webproject/error/main.py", line 6, in <module>
def_function()
TypeError: def_function() missing 1 required positional argument: 'name'
Wrong code line
def_function()
Correct code line
def_function(name)
- Wrong action: def_function()
- Correct action: def_function(name)
Entire Correct Code line
def def_function(name):
print(f"hello {name}")
name = input("What is your name:")
def_function(name)
What is () missing 1 required positional argument:?
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 one argument like name or any other and we do not specifically then we face this issue.
How to fix () missing 1 required positional argument:?
If you want to fix this error then we need to enter expecting at least one argument in my case this is a named variable but in your case may be, this is different. For more clarification see the above example.
For more information Visit YouTube Channel.
