How do you explain these 2 outputs | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do you explain these 2 outputs

run print("hallo" + " world"), result: hallo world but if you run: print("hallo", "world"), result would be: ("hallo", "world") notice the second one has quotation mark and brackets included while the first one has only the letters. why?

11th Jul 2017, 3:02 AM
yubin wang
yubin wang - avatar
3 Answers
+ 8
The first is an ordinary string concatenation while the second one is an array(tuple) ...so it adds spaces in between it's it's items by default!
11th Jul 2017, 3:18 AM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
+ 4
Hmm... I'm pretty sure print("Hallo", "world") just prints Hallo world No brackets, no quotes...
11th Jul 2017, 5:53 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 3
How about writing those two lines of code and saving them as a public code and posting the link here?
11th Jul 2017, 6:21 AM
David Ashton
David Ashton - avatar