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


Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  difference between forms of input a list to function akbarza 6 1,037 Feb-21-2024, 08:02 PM
Last Post: bterwijn
  Syntax error for "root = Tk()" dlwaddel 15 1,188 Jan-29-2024, 12:07 AM
Last Post: dlwaddel
Photo SYNTAX ERROR Yannko 3 390 Jan-19-2024, 01:20 PM
Last Post: rob101
  Syntax error while executing the Python code in Linux DivAsh 8 1,609 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Code is returning the incorrect values. syntax error 007sonic 6 1,233 Jun-19-2023, 03:35 AM
Last Post: 007sonic
  syntax error question - string mgallotti 5 1,319 Feb-03-2023, 05:10 PM
Last Post: mgallotti
  Syntax error? I don't see it KenHorse 4 1,262 Jan-15-2023, 07:49 PM
Last Post: Gribouillis
Information How to take url in telegram bot user input and put it as an argument in a function? askfriends 0 1,096 Dec-25-2022, 03:00 PM
Last Post: askfriends
  Syntax error tibbj001 2 896 Dec-05-2022, 06:38 PM
Last Post: deanhystad
  [Solved] unkown (to me) function def parm "name1:name2" syntax. MvGulik 5 1,074 Nov-11-2022, 11:21 AM
Last Post: MvGulik

Forum Jump:

User Panel Messages

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