Use of print "str1" + "str2"


I expect that print command ends with first "str1 " but there are two strings so shouldn't they both be inside something like brackets to work.

Replace this line with your code. Do not remove the backticks that are above or below this line.
print "Spam "+"and "+"eggs"

my doubt is that shouldn't the print command end at "Spam" since print will look for two "


Could you please print your code so we can help you check what's wrong?


i have added the code


I know nothing about Python (but it's quite similar to Ruby) but I think why it will print the whole line:

It will use concatenation which will add the string together before printing it.


If the concatenation operators are in the quote marked string, they will print. Think of it in terms like this:

str1 = "start of string "
str2 = "middle of string "
str3 = "end of string"
print str1 + str2 + str3

# start of string middle of string end of string


thanks that cleared my doubt perfectly