0
Simple calculator
Hello, there. I am trying to do a simple calculator with two inputs. I used this code: x = int(input()) y = int(input()) z = x + y print("The result is " + z) But I can't get it right. The result I want is the sum of input 1 and 2. Can someone help me understand? Thanks. :)
3 Answers
+ 3
Alexandre Leal
You cannot concat number with string in python.
To do that you need to cast number with str function:
print ("The result is " + str(z))
+ 2
You should do it like this....
x = int(input())
y = int(input())
z = x + y
print("The result is ", z)
Don't use + in print. Use , instead of +.
+ is used for concatenation
+ 1
Thank you, man. I didn't notice that. :D