+ 1
Why does this not produce num1 plus num2 as a calculation?
num1 = input("Enter a number: ") num2 = input("Enter a number: ") print(int(num1 + num2))
6 Respuestas
+ 4
num1 = int(input("Enter a number: "))
num2 = int(input("Enter a number: "))
print(num1 + num2)
Try this.. Default input is string so parse/convert the input itself
+ 4
You are adding strings and then converting it to int
0
Try int(input('enter number'))
Gotta switch the type
0
Always remmeber : by default input from the user is always a string...
So:
You need to convert it to an int by using int() function...
That is ....num1 = int(input())
Suggetion...use float() ..function when dealing with decimal numbers...