+ 5

Python Input in Code Playground

My code is: age = input("What is your age? \n") print ("Your age is " + age) However, when receiving user input, it doesn't state the text for the input until after the user gives an input. In the input box, it simply says "Seems like your program requires input" Is there a different kind of input in Python that acts more like a prompt in JS? I don't really understand how getting input from the user is helpful if they don't know the specific reason they are giving input.

21st Jan 2019, 3:25 AM
melzs0627
melzs0627 - avatar
5 Answers
+ 6
This is how the SL Code Playground operates. If you were to use IDLE, it'd do what you are asking for.
21st Jan 2019, 3:29 AM
Dread
Dread - avatar
+ 6
age = int(input("what is your age")) print ("your age is" + age)
22nd Jan 2019, 2:47 AM
sanjeev
sanjeev - avatar
+ 3
You could use a different IDEA if you want to see that. This is Solo learn Code Playground so this is how things work here.
21st Jan 2019, 3:35 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
Your code would do, what you intend (but fix the datatype as written above). But "input("") not work korrect on SL. Try the app "Pydroid" for checking your code. The ide in SL dont work in this way. ------------------------------------------------------------------ kk, it seems, this answer isnt enough. Edit: In python, there are different datatypes. In example "a" is datatype string. Try print(type("a")) You see: <class 'str'> in which str means string. input expect the datatype str. So you have to convert it. x = int(input("something")) I recoment Pydroid, cause its a mobile Python ide. You can test, if input("some words") returns the "some words" as promt.
22nd Jan 2019, 6:49 AM
Sven_m
Sven_m - avatar
0
Input func . Input the string data type convert it to integer
22nd Jan 2019, 3:10 AM
Jatin
Jatin - avatar