Learn Python the Hardway exercise 11 question 4

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Mar 31 03:53:02 EDT 2011


On Wed, 30 Mar 2011 20:03:09 -0700, Joseph Sanoyo wrote:

> print "How old are you?", age = raw_input() print "How tall are you?",
> height = raw_input() print "How much do you weigh?", weight =
> raw_input() print "So, you're %r old, %r tall and %r heavy." % ( age,
> height, weight)
> Note:
> Notice that we put a , (comma) at the end of each print line. This is so
> that print doesn’t end the line with a newline and go to the next line.
> What You Should See
> Extra Credit
> 1. Go online and find out what Python’s raw_input does. $ python ex11.py
> How old are you?
> 35 How tall are you?
> 6'2" How much do you weigh? 180lbs
> So, you're '35' old, '6\'2"' tall and '180lbs' heavy.
> 
> Related to escape sequences, try to find out why the last line has
> ’6\’2"’ with that \’ sequence. See how the single-quote needs to be
> escaped because otherwise it would end the string?

I'm sorry, are you asking a question and expecting an answer, replying to 
somebody else's question, or just sharing something you thought was 
interesting?


-- 
Steven



More information about the Python-list mailing list