String Formatting with %, Part 2


#1




<<i keep getting this error

Traceback (most recent call last):
File "python", line 5, in
ValueError: unsupported format character ',' (0x2c) at index 21

and im not sure what the issue is. please help, thanks!


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)


#2

Use () with print statement.

print ("Ah, so your name is %, your quest is %, and your favorite color is %." % (name, quest, color))

#3

You should also write %s instead of %. The pharentheses have no matter


#4

() do matter in python 3.


#5

Mmm sorry you are right, forgot what I said. (In this lesson it let's you to the next exersice)


#6

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)


#7

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