+ 1
what is difference between "+" and simple "," during concatenation of strings??
Example : print('HI '+ "krishna") print("Hi", "krishna") OuTpUT: HI krishna Hi krishna
5 Answers
+ 3
When you use a comma it isn't concatenating the strings it is just printing both arguments separated by " ".
+ 2
In most cases + are used when ur add up a string like an increment while "" are used for putting text together.
+ 1
print is a function you can call with as many arguments as you want, for example:
x = 0
print('Hello', 5, True, x)
By default, in the output all arguments will be separated by a space, but you can change this, using 'sep':
print(1, 2, 3, sep='_')
This leads to 1_2_3.
However, if you write 'Hello ' + 'World', your two strings will become one string FIRST and then passed to print as only one argument.