Hello. I was confused between + and ,
It seems like their functions are the same. What’s the difference between + and ,
Thank you for your help.
Hello. I was confused between + and ,
It seems like their functions are the same. What’s the difference between + and ,
Thank you for your help.
If you are referring to print()
, the difference is that +
is string concatenation, giving a single object as the argument. When commas are used to separate arguments, they retain their data type.
print ("PI = ", 3.14)
versus
print ("PI = " + str(3.14))
To add onto mtf’s answer, in general, when you use commas between items like so:
a = "hello", "world"
You actually end up creating a tuple (which is like a list, but can’t be modified):
print(a)
>> ("hello", "world")