+ 2

Simple Calculator, Python

I do not understand what I am doing wrong, I enter the following code: x = input (6) y = input (3) fun = int (x) + int (y) print (fun) The result should after the test give 9, but my result gives 639

21st Feb 2021, 3:33 PM
Benny
Benny  - avatar
3 Antworten
+ 2
Actually, the result is correct, but the input function prints the numbers in the brackets as well. Leave input() empty, input two numbers and see the difference
21st Feb 2021, 3:40 PM
Lisa
Lisa - avatar
+ 4
input is used to ask user to enter a value (string) if you give an argument to input, it will be displayed to user just before waiting response (but in sololearn you must provide all input at once, each separated by new line) x = input("First number? ") y = input("Second number ? ") fun = int(x) + int(y) print("sum of",x,"+",y,"=",fun)
21st Feb 2021, 3:41 PM
visph
visph - avatar
+ 4
It is taking 6 and 3 as Strings. x=int(input ()) Use this to run your code properly
21st Feb 2021, 3:42 PM
Atul [Inactive]