String formatting


#1

help

https://www.codecademy.com/courses/python-beginner-sRXwR/3/4?curriculum_id=4f89dab3d788890003000096#

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")

https://gyazo.com/d55c813d774b5735b267663956557f8e


#2

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 quotes.like

(name, quest, color)


#3

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