Python calculator does not calculate -


this question has answer here:

i have simple calculator app here, meant add 2 numbers make number, different.

code:

num1 = input() num2 = input() answer = num1+num2 print (answer) #does different 

instead of adding, puts 2 variables together. example, 2+2, 4. when doing in app, shows 22. reason why? , how can fix it?

that's because takes string, not integer values. convert them both int , problem solved.

num1 = int(input()) 

and on.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -