String formatting



Oops, try again. Make sure to use a lowercase "s" with \%s. Python told us about the following error: unsupported format character ',' (0x2c) at index 21

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 %, your quest is %, " \
"and your favorite color is %." % ("name", "quest", "color")


to add a string value

Remember, the syntax is:

print "%s" % (string_variable)

so your code should be like

Ah, so your name is %s

you missed all s after %

and the variable you wrote inside paretheses should be without

(name, quest, color)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.