Python Forum
I'm getting syntax error while using input function in def.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I'm getting syntax error while using input function in def.
#1
Star 
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():

   
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
   
Larz60+ write Oct-06-2021, 10:31 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please avoid using images for code.
Reply
#2
You have args in your function but none of them are set.
def (name, age, address):
None of these are set.
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts


Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to use pyinstaller results in a syntax error mark1969 2 58 Apr-15-2026, 01:59 PM
Last Post: snippsat
Question Two arguments in input function Alfredd 4 811 Nov-09-2025, 12:56 AM
Last Post: Pedroski55
  Using a For Loop to subtract numbers from an input function. Anunderling 9 2,819 Sep-22-2025, 08:56 PM
Last Post: deanhystad
  Input function oldschool 1 1,255 Sep-14-2024, 01:02 PM
Last Post: deanhystad
  POST Syntax error amplay 0 1,387 Aug-07-2024, 02:43 PM
Last Post: amplay
  Input error correction. shakoun 4 2,455 Jun-07-2024, 12:59 PM
Last Post: menator01
  is this really a syntax error? Skaperen 4 2,552 May-25-2024, 07:31 AM
Last Post: snippsat
  World Clock syntax error OscarBoots 1 1,759 May-03-2024, 05:20 AM
Last Post: snippsat
  difference between forms of input a list to function akbarza 6 3,499 Feb-21-2024, 08:02 PM
Last Post: bterwijn
  Syntax error for "root = Tk()" dlwaddel 15 10,783 Jan-29-2024, 12:07 AM
Last Post: dlwaddel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020