I am self teaching myself python and I have hit a question that I can't seem to figure out dealing with raw_input.

This is the code that is confusing me:

print "How tall are you?",
height = raw_input()

print "So, you're %r tall ." % (height)

I input my height as 5' 10" and get the follwing output:

How tall are you? 5' 10"
So, you're '5\' 10"' tall .

What am I missing from my code to fix the output so it reads properly?

Votes + Comments
Great first post/thread
5 Years
Discussion Span
Last Post by reddsoxy

%s, not %r: str not repr.

height = raw_input("How tall are you? ")   
print "So, you're %s tall." % height

Edited by pyTony


%r is repr, the official representation, which can be evaluated to yield the same value of same type. In case of strings it includes the quotes.

%s is str, the output for humans form, which does not include quotes/escapes.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.