14th Apr 2019, 11:43 AM
Piyush Kumar
Piyush Kumar - avatar
7 Antworten
+ 3
You probably want to add num1 and num2, so you should change result = int(input() + input()) to result = num1 + num2. Otherwise the program will ask for input five times and num1 and num2 won't be used anywhere
14th Apr 2019, 11:48 AM
Anna
Anna - avatar
+ 3
Instead of: print(int(input() + input()) Just say: print(num1 + num2) With the former statement it would have done this: * example input = 2, 3 Output: 23 The reason for this is that you added two strings, then converted the result into an integer You also would have had to give 4 inputs (2 of which were unneccecary) Also the indentation is wrong. It should be: if {condition}: {code} Here is the fixed code according to the fixes I mentioned: https://code.sololearn.com/cZE3G7g7bwA8/?ref=app
14th Apr 2019, 11:51 AM
Trigger
Trigger - avatar
+ 2
Piyush Kumar If all the following are true: - no error is raised - the result is what you expected to be given the input. 2 + 5 should NOT be 25🐍
14th Apr 2019, 12:40 PM
Trigger
Trigger - avatar
+ 1
How can I check if the output is right or wrong?
14th Apr 2019, 12:38 PM
Piyush Kumar
Piyush Kumar - avatar
0
Piyush Kumar you must add a tab before each line in if block
21st Apr 2019, 7:10 PM
Sousou
Sousou - avatar
0
#so it will be: user_input = input(": ") if user_input == "add": num1 = float(input("Enter")) num2 = float(input("Enter")) result = str(num1 + num2) print(result)
21st Apr 2019, 7:12 PM
Sousou
Sousou - avatar