I am using Geany to code and Ubuntu 16.04 as my OS. when I enter this code
print("Result:",a+b)
It gives it's output as ('Result:', a+b)
.
I am using Geany to code and Ubuntu 16.04 as my OS. when I enter this code
print("Result:",a+b)
It gives it's output as ('Result:', a+b)
.
In python 2:
print("Result:",a+b) --> # ('Result:', 6)
parens are no needed, because otherwise we are printing a tuple of two elements: string 'Result'
and an integer 6
.
In python 3:
print("Result:",a+b) --> # Result: 6
parens are needed, just because print is a function instead of a statement in python 3.
So to do it the same in python 2 which is in python 3, you have to do this:
print "Result:", a+b --> # Result: 6