0

Wrong Output? print (float(input("What is your age: ")) + float(input("Your spouse's age: ")))

Why does the playground give wrong output for the following code, Command: print (float(input("What is your age: ")) + float(input("Your spouse's age: "))) Output: What is your age: Your spouse's age: 70.0 Or am I doing something wrong here? When tried in Python IDLE it gives the right output as I expect.

20th Jan 2018, 4:20 PM
Dhruuv Sharma
Dhruuv Sharma - avatar
1 Respuesta
+ 3
Most likely you are confused about how SoloLearn works. Before your program starts running and it appears the program needs input, you get your one and only chance to enter data with the popup alert. You must enter each input on a separate line for everything your program is going to need. That data is sent to a server which compiles (if required) and runs the program to completion or system timeout limit (around 5 seconds depending on server load.) Afterwards, the output is sent back to your device for display. Your program line worked perfectly for me having entered: 69.7 49.7
21st Jan 2018, 12:27 AM
John Wells
John Wells - avatar