Python Forum

Full Version: I'm getting syntax error while using input function in def.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Please tell me what is wrong and why it is wrong? what is wrong with indentation? please explain
Error when input() is given below def():

[attachment=1304]
def details(name,age,address):
    name=input("Enter your name\n")
    age=input('enter age\n')
    address=input('Enter address\n')
    print(f'Hello: {name}')
    print(f'So you are {age} old')
    print(f'Your address is {address}')
details(name,age,address)

TypeError: details() missing 3 required positional arguments: 'name', 'age', and 'address' 
 For above code if parameters are not given the code works
def details():
    name=input("Enter your name\n")
    age=input('enter age\n')
    address=input('Enter address\n')
    print(f'Hello: {name}')
    print(f'So you are {age} old')
    print(f'Your address is {address}')
details()

O/P
Hello: 22
So you are 22 old
Your address is 22
If parameters are given this indentation works
def details(name,age,address):
    print(f'Hello: {name}')
    print(f'So you are {age} old')
    print(f'Your address is {address}')
name=input("Enter your name\n")
age=input('enter age\n')
address=input('Enter address\n')
details(name,age,address)

O/P
Hello: 22
So you are 22 old
Your address is 22
[attachment=1305]
You have args in your function but none of them are set.
def (name, age, address):
None of these are set.