0
how to add two numbers .. accepting it from the user .. because 2+2 shows 22
5 Respostas
+ 6
a = input("number1")
b = input("number2")
add = int(a) +int(b)
print(add)
+ 4
the input of the user is always a string. Because of that you have to convert the input in integers, first before adding them.
+ 2
This happens because of input() function take input as a string.
In your case when you in put 2 it take is as "2"
so "2"+"2"="22"
So you have to convert it in to integer.
for this CRIS also show an example and another way is take it directly in to integer.
i.e. X = int(input("Input Number 1: "))
+ 1
any user input is considered to be a string. you have to convert it before adding it together
- 2
a=raw_input("num1 :")
b=raw_input("num2 :")
print a,b