15/16 , Why "\" is used for concatenating?


#1

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, " \ -----> Why "\" is used instead of "+" for concatenating?
"and your favorite color is %s." % (name, quest, color)


#2

@gmaravind hey I'm new to this so take it with a grain of salt. But I think the backslash is used to tell python to treat that as one line of code, despite it being actually written as two lines of code. I think you would be able to use "+" and write it out in the editor as one line and it should run fine. Again I'm new, but hope that helps.


#3

\ is not used for concatenating in the programmatic sense, but for the IDE itself to be able to recognize when we have broken a string or expression with a line break which is then ignored by the interpreter/compiler.