Why does 15 use a slash to concatenate?


#1

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?


#2

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


#3

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

#4

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

--rookie