0
I don't understand what's wrong with my code
Sololearn asked me to make a simple calculator program that adds numbers together. I don't understand what is wrong with my code n = input("") m = input("") o = n + m print(o) If n is 1 and m is 2, the code returns 12. Why?
5 Answers
+ 5
Thats because n and m are strings
It shoud be
n=int(input(""))
m=int(input(""))
đ
+ 2
n = input()
m = input()
o = n + m
print(o)
Means: string + string
n = "1"
m = "2"
Print(n + m )
Output: 1 2
to input a number u can use int ()
for example :
int(intput())
now the output will be 3
+ 1
If this is relevant, I am doing the Python Core course.
0
Thanks for the help Nadir Nadir HrCoder
0
Hi, The values ââyou receive string so first of all you must transform intager this values
n =int(input("enter a number" ) )
Like this