String formatting with % part 2 help?


#1

I am clueless on this one.


#2

@jeanclaudevan-damme,
Doing a google search
formatting string site:https://docs.python.org/2
will give you a load of =article's=
like
https://docs.python.org/2.4/lib/typesseq-strings.html
or
https://docs.python.org/2/library/string.html

OR
a google search
python formatting a string output site:stackoverflow.com
http://stackoverflow.com/questions/5082452/python-string-formatting-vs-format


#3

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)


#4

print "Ah, so your name is %s, your quest is %s, " \
"and your favorite color is %s." % (name, quest, color)
there is a " before . Why is not a wrong?
I think the right version is
print "Ah, so your name is %s, your quest is %s, \" \
"and your favorite color is %s." % (name, quest, color)


#5

What you pasted works only in the online Code Academy editor but when I copy and paste it into Notepad++ on my PC and run it via Python, then it gives an error. The exact same code in other words that works for this lesson, does not actual work in Python itself...any explanation for this?
Code below:
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)