+ 1

Why my code is not working??

a = input ("Enter your name: ") b=input("Enter your age: ") print("Hello!" ,a,"You are ", b)

9th May 2021, 5:06 PM
Devang
Devang - avatar
26 Antworten
+ 7
https://code.sololearn.com/ceveJF53m6Sl/?ref=app U code is running . But why still u have problem in that..🤔
9th May 2021, 5:09 PM
Kǟrɨsɦmǟ ❥
Kǟrɨsɦmǟ ❥ - avatar
+ 7
Devang But for me it's running alright. Can u tell me what u gave input to it.
9th May 2021, 5:17 PM
Kǟrɨsɦmǟ ❥
Kǟrɨsɦmǟ ❥ - avatar
+ 5
Devang See the code which I had shared above it's working . And it's the one which u have written .
9th May 2021, 5:14 PM
Kǟrɨsɦmǟ ❥
Kǟrɨsɦmǟ ❥ - avatar
+ 2
Please show error message
9th May 2021, 7:39 PM
Oma Falk
Oma Falk - avatar
+ 2
Hi Devang, I think you are entering the input like this "Devang 17" . This will give error as your program requires 2 inputs separated by a newline \r\n character. Try inputting like this ( by pressing nextline on keypad ): Devang 17 This will give you correct result. Regards Roshan
11th May 2021, 12:11 PM
Roshan Kumar
Roshan Kumar - avatar
+ 1
Just change the age into int
9th May 2021, 5:10 PM
Atul [Inactive]
+ 1
Not working in mine miracle
9th May 2021, 5:11 PM
Devang
Devang - avatar
+ 1
a = input ("Enter your name: ") b=int(input("Enter your age: ")) print("Hello!" ,a,"You are ", b) #My attempt
9th May 2021, 5:15 PM
Atul [Inactive]
+ 1
💖..₥łⱤ₳₵ⱠɆ..💖 sorry but it's showing error
9th May 2021, 5:16 PM
Devang
Devang - avatar
+ 1
Should work with no problems and for the people commenting use "+" instead of "," and cast age as int.. you can print anything and everything using "," but with an automatic space whereas "+" is used for concatenation of strings, in which case you have to cast numbers and all as str().
11th May 2021, 4:33 AM
Henry Pangsatabam
Henry Pangsatabam - avatar
+ 1
its actually working, you just need to input in this format "example 17"
11th May 2021, 8:43 AM
senz
senz - avatar
+ 1
It's right
11th May 2021, 3:09 PM
Naman Tiwari
+ 1
You did great with the input but you need to concatenate the strings using "+" Like this print("Hello " + a +"You are "+ str(b))
11th May 2021, 3:37 PM
Alto
Alto - avatar
+ 1
Alto this would invoke a ValueException. I wrote in my reply that he/she should use str() to cast the variables to the string type. Sadly people think its okay to simply concatenate different types and disregard the add operator. Sure you might have no issues now but irl and outside of python, so the rest of the programming field, you will have massive issues with implicit variables.
11th May 2021, 3:38 PM
Wheres8
Wheres8 - avatar
+ 1
Wheres8 yeah ur write but he only need to typecast the integer For the age print("You are "+str(b)) Is not it
11th May 2021, 3:41 PM
Alto
Alto - avatar
+ 1
@Alto Logically correct but its always good practise to make sure everything is right. You dont know what the user will send for both a and b, always good to take caution. Beginners who had Python as their first language have massive understanding issues when it comes to languages like C, C++, Java etc... Dont even look at 8086 Assembly. I think python should be used as a quick hacky language that you use because you already have programmed network sockets etc... in C and need to test stuff. It takes away so much learning and real world information such as pointers or programming logic (python: all wrapped in one function but the beginner doesnt/will never know what happens beneath the hood).
11th May 2021, 3:52 PM
Wheres8
Wheres8 - avatar
0
B = int(input())
10th May 2021, 1:37 PM
Richard Horvatich
Richard Horvatich - avatar
0
There's nothing error in your code because I tried it in pydroid 3 and it's working.
10th May 2021, 6:03 PM
Muhammad Abdulmalik
Muhammad Abdulmalik - avatar
0
This code is not working when You have only 1 input lane in "input". If U press enter/return and create new lane this work fine. Else not work and got crashed coz of SoloLearn.
10th May 2021, 9:14 PM
Konrad Wojda
Konrad Wojda - avatar
0
HEY, BRO THIS NOT IDE THIS ANDROID APP HOW TO WORK FOLLOW ME RUN CODE SUMIT OPTION ONLY ONE TIME OPTION value add NAME AGE ___________________________ SUMIT OUTPUT DEAD 0
11th May 2021, 7:06 AM
D I Av
D I Av - avatar