% operator after a string is used to combine a string with variables. The %operator will replace a %s in the string with the string variable that comes after it.string_1 = "Camelot"
string_2 = "place"
print "Let's not go to %s. 'Tis a silly %s." % (string_1, string_2)
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)
沒有留言:
張貼留言