[Tutor] Other ways to use raw_input function

amt 0101amt at gmail.com
Tue Oct 18 19:58:28 CEST 2011


Greetings! I got stuck at an exercise from the book learn python the hard
way about raw_input function.(exercise 11.2)

After reading from docs.python.org I found out that this function can
perform standard output without a trailing newline.Also it can take an input
line, convert it as a string( stripping a trailing newline) and return it.


The exercise question is : Can you find other ways to use it?

Here is the original code from the book:

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)



Now, the only different way I was able to use raw_input is:


age = raw_input("How old are you? ")

height = raw_input("How tall are you? ")
weight = raw_input("How much do you weigh? ")

print "So, you're %r old, %r tall and %r heavy." % (age, height, weight)



Are there any other ways of using it? If yes can you please give me a
detailed example so I can understand.

Thanks in advance,
amt.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111018/f2c03cb2/attachment.html>


More information about the Tutor mailing list