Python calculator does not calculate -
this question has answer here:
- how can read inputs integers? 14 answers
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
Post a Comment