Could anyone please explain the last line of this code?


#1

Please leave the following link in the post so we can find the unit module, else replace it with a link to the exact lesson:

Strings and Console Output

  1. name = raw_input("What is your name? ")
  2. quest = raw_input("What is your quest? ")
  3. color = raw_input("What is your favorite color? ")
  4. print "Ah, so your name is %s, your quest is %s, "
    “and your favorite color is %s.” % (name, quest, color)

The output shows line 1,2 and 3 accordingly but for line 5 I get Ah, so your name is , your quest is , and your favorite color is . Why doesn’t it shows the code like this your name is name, your quest is quest and your favorite color is color. Shouldn’t the % sign replace the %s with name variables (names, quest and color)? Furthermore, what is the function of raw_input? I would really apreciat eyour help. Thanks in advance


#2

once you press the run button, the program will execute/run

while the programming is running, raw_input is prompting the user of the program (in this case you) for input, so it allows you to capture user input! Which is really useful

if you actually enter something, you will see this in the final result of the program


#3

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