Friday, June 6, 2014

Day 62

Explored Python at CodeCademy. Worked on Python tutorial 15 of 16, Strings & Console Output, String Formatting with %, Part 2. Learned more on how to print a variable with a string without concatenating strings together.

The code used:
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)

The interaction looked like this:
What is your name? Gandalf
What is your quest? Gray to White
What is your favorite color? Red
Ah, so your name is Gandalf, your quest is Gray to White, and your favorite color is Red.

No comments:

Post a Comment