Print problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Print problem

Why should we put spaces like this: Print(“Knowledge “ + “is “ +”power”) If we wanna show Knowledge is power. Can’t we just do it without spaces?

9th Jan 2023, 9:43 PM
MG Adnama
3 Answers
+ 1
Hello, If you do it without spaces, you will get: **Knowledgeispower** . This is the reason why you add space, at the end of each sting. This is just shown for the purpose of string concatenation (combining two strings together), but it's quite useful. However, you can do it alternatively: print("Knowledge is power") OR: print("Knowledge", "is", "power") Notice that we don't put spaces at the end of the string. This is because comma (,) automatically makes spaces, and allows to combine different data types into one output of the print() function, such as strings and integer, e.g. print("Armin is", 20, "years old")
9th Jan 2023, 9:55 PM
Lamron
Lamron - avatar
+ 1
Ohhh I get it now, thanks sm
9th Jan 2023, 9:55 PM
MG Adnama
+ 1
Use a comma instead of "+"
9th Jan 2023, 9:56 PM
Solo
Solo - avatar