What's the difference? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 4

What's the difference?

print("I", "love", "Python") VS print("I" + " love " + "Python") What is more efficient? And more readable?

15th Jan 2021, 9:46 PM
Giuseppe Pipitò
3 ответов
+ 2
, is to sperate by a space + just adds it on directly to the end of the string before
15th Jan 2021, 9:47 PM
Slick
Slick - avatar
+ 2
With using comma separator you just give arguments to print functions but with plus sign you do a string concatenation to create a new string.What is better depends on your need in core code used for.
15th Jan 2021, 10:27 PM
HBhZ_C
HBhZ_C - avatar
+ 2
Just an additional With using comma, you can costumize what that comma represents By default, comma means whitespace. But you can change the "sep" or comma with whatever character you want. For example: print("This", "is", "a", "string", sep="@@") >> This@@is@@a@@string
16th Jan 2021, 3:13 AM
noteve
noteve - avatar