Why does 15 use a slash to concatenate?


I know that the answer that works is:

name = raw_input("What is your name?")
quest = raw_input("What is your quest?")
color = raw_input("What is your favorite color?")

print "Ah, so your name is %s, your quest is %s, " \
"and your favorite color is %s" % (name, quest, color)

But why do you use the slash \ to concatenate? I tried using a + with the interpreter I have on my computer as well and it told me it was the wrong syntax. Is this specific to using %s?


The backslash () character is used to escape characters that otherwise have a special meaning, such as newline. In this case we are using it for multiline strings


So you are using it to continue the print function basically since python considers whitespace and newlines as meaningful in syntax?
This then leads me to a second question, does python concatenate automatically if you have two strings nested in quotation marks?

I guess kind of like let's say bash would interpret arguments?:

sudo apt-get install firefox gedit mousepad


why doesn't work if you leave the slash out....after all it should concatenate or execute by language order."