Let me illustrate onpon4's statement:

Python 3
---------
num = input()

# input a number, let us say 5

sum = num + num

Print (sum)

55 # concatenation of two strings '5' and '5'


Python 2
---------
num = input()

# input a number, let us say 5

sum = num + num

Print (sum)

10  # sum of two integers 5 and 5

To get this result of 10 using Python 3 you can do the following:

Python 3
---------
num = int( input() )  # convert input to an integer

# input a number, let us say 5

sum = num + num

Print (sum)

10  # sum of two integers 5 and 5

Conclusion: In Python 2 the result of input() is an int while in Python 3 the result of input() is a string.

Reply via email to