print ("hello"+"world)
or
print ("hello"
+"world")
would give the output as:
hello world
however, when I try to insert a variable (int) into the print functions along with 'str' using '+', there's an error. But, when I use ','s instead, it is designed to work. That is:
x=1
print("the value of 'x' is " + x + ".")
it shows the error
TypeError: can only concatenate str (not "int") to str
But when I use:
print("the value of 'x' is ",x,".")
I get the desired output.
I would like to know why is python designed this way, what is the meaning of using '+' in this context. Thankyou.
Edit: Thanks for the replies, the intent was because in Java + means to simply put together.