what is difference between "+" and simple "," during concatenation of strings?? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula gr√°tis
+ 1

what is difference between "+" and simple "," during concatenation of strings??

Example : print('HI '+ "krishna") print("Hi", "krishna") OuTpUT: HI krishna Hi krishna

5th Nov 2018, 3:57 AM
Sai Krishna
Sai Krishna - avatar
3 Respostas
+ 3
When you use a comma it isn't concatenating the strings it is just printing both arguments separated by " ".
5th Nov 2018, 8:47 AM
Shuaib Nuruddin
Shuaib Nuruddin - avatar
+ 2
In most cases + are used when ur add up a string like an increment while "" are used for putting text together.
12th Dec 2018, 3:01 PM
Koye
Koye - avatar
+ 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.
5th Nov 2018, 9:22 AM
HonFu
HonFu - avatar