+ 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
3 Respuestas
+ 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
+ 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)
+ 4
It is taking 6 and 3 as Strings.
x=int(input ())
Use this to run your code properly