Same code gives different output in python2 and python3

Below code gives different o/p in python 2 and python 3

def add(x,y):
try:
sum = x + y
except:
(“Error in Processing”)
return sum

x = input("Enter first number: ")  
y = input("Enter second number: ")       
sum = add (x,y)
print(sum)

python 2 : 33 python 3 : 1122

Any ideas???

Hi, Ashish.

The input() will take the inputs as string datatype.You need to convert to int, if you need to use it as integer otherwise it will do string concatenations rather than adding the numbers.
So type cats into int.

x = int(input("Enter first number: ") )
y = int(input("Enter second number: ") )

Kindly refer the lectures, it is all covered and beautifully explained in Python lectures.

All the best!