- 3

name = input() age = input() print(name + " is " + age)

Why this code resulting error plz help anyone

8th Aug 2021, 4:57 AM
Akash Kumar
27 Respostas
+ 4
Calvin Thomas Yes that will also work but print statement is already given in practice code. We just have to change Hard Code input to user input.
8th Aug 2021, 5:22 AM
A͢J
A͢J - avatar
+ 4
The code is correct but when you give the input, do it on different lines. Eg. On the first line write the name and then on the second line write the age.
8th Aug 2021, 5:36 AM
Aashi Sood
Aashi Sood - avatar
+ 2
Your name in first line and your age in 2nd line
8th Aug 2021, 5:05 AM
Atul [Inactive]
+ 2
Your code is correct friend, I think your complier may have some error, just update it.
8th Aug 2021, 8:30 AM
SAI PAVAN TM
SAI PAVAN TM - avatar
+ 2
Mohammad Hasan no, even if age is a number, we can still store it as a string. Remember '0', '1', etc are characters; only 0,1,etc are numbers
8th Aug 2021, 12:04 PM
Rishi
Rishi - avatar
+ 2
Rishi I've already forgotten that:( (I started learning again today)thanks for telling me my mistake:)
8th Aug 2021, 12:08 PM
Mohammad Hasan
Mohammad Hasan - avatar
+ 2
just remove double quotes from is and place it in starting and ending of brackets but place it inside and at last do semicolon after the bracket is closed
8th Aug 2021, 12:59 PM
Pratham soni
Pratham soni - avatar
+ 2
There a many ways of formating text in python , they include the following print(f"{name} is {age}) print(" {} is {}".format(name, age)) print(" %s is %d"%(name, age))
8th Aug 2021, 1:14 PM
Caleb Oguntunde
Caleb Oguntunde - avatar
+ 2
Guys his code is write just output is incomplete. It's a problem of practice 17.2 in Python For Beginners course.
8th Aug 2021, 1:27 PM
A͢J
A͢J - avatar
+ 2
There are not problem with formatting, Akash Kumar Here is answer on your question You should split multiple input into separate lines Please like if it helps 🙂 https://ibb.co/vx9L4gK https://ibb.co/QQpzrfG Ash wrote: The code is correct but when you give the input, do it on different lines. Eg. On the first line write the name and then on the second line write the age. 👍
8th Aug 2021, 3:41 PM
E A
+ 2
It will give Syntax eror.
8th Aug 2021, 6:44 PM
Adhya Vyas
+ 2
I mean it will give Syntax eror
8th Aug 2021, 7:05 PM
Adhya Vyas
+ 2
Form my view
8th Aug 2021, 7:06 PM
Adhya Vyas
+ 2
correction age=int(input()) and on a second line
8th Aug 2021, 9:43 PM
Tomilola Oluwafemi
Tomilola Oluwafemi - avatar
+ 1
Akash Kumar Your code is write but I think you didn't check problem statement properly. Your output should be this: print(name + " is "+age+" years old")
8th Aug 2021, 5:06 AM
A͢J
A͢J - avatar
+ 1
Thanks Atul
8th Aug 2021, 5:07 AM
Akash Kumar
+ 1
This also works: print(name, "is", age, "years old")
8th Aug 2021, 5:11 AM
Calvin Thomas
Calvin Thomas - avatar
+ 1
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ Oh, didn't quite realize that. Thanks for the correction.
8th Aug 2021, 5:34 AM
Calvin Thomas
Calvin Thomas - avatar
+ 1
The code works try using another compiler, or try using string concantination, Im not really sure of the syntax(not a pythonista) but you can check it out
8th Aug 2021, 10:19 AM
Fatoki Temiloluwa
+ 1
Use the format method, it is usefull in these cases
8th Aug 2021, 10:52 AM
Leonardo Migliorelli
Leonardo Migliorelli - avatar