Mohamed Ashraf Mohamed Ashraf - 1 month ago 6
Python Question

How can I add two variable and assign to result variable in Python?

I am very new to python world,Please help me how to concatenate str and int objects.

a = 100
b= 200
c = 'Result ='
print (c + a + b)


Throwing error

>>> print (c + a + b)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects


I looking output as, Result = 300

Thank in advance...!!!

Answer
a = 100
b = 200
c = 'Result = '
print (c + str(int(a + b)))