[Tutor] help on raw_input()

Alan Gauld alan.gauld at btinternet.com
Sat Apr 14 09:36:00 CEST 2007

"ammar azif" <ceasar102 at yahoo.com> wrote

> i wanted to get a string from raw_input like this
> raw_input('>')
>> \n\nsomestring

OK, Can you explain precisely what you want the string to contain.
\n is the string representation of a newline. Do you want to enter 
something that starts with two newlines? Or do you literally want
the sequence \,n,\,n?

If its the latter thats what Python has stored. The double slash 
is only there when python displays the result (Try using len and 
comparing if you aren't convinced)

If you want to actually capture newline characters from raw_input, 
thats more tricky. But before we get to that can you clarify what 
you actually want?

Alan G.

More information about the Tutor mailing list