Typing \n in strings

Edward Diener eldiener at earthlink.net
Sat Apr 3 22:23:20 EST 2004


Paul Watson wrote:
> "Edward Diener" <eldiener at earthlink.net> wrote in message
> news:RGKbc.11130$yN6.10939 at newsread2.news.atl.earthlink.net...
>> Python 2.3.3 on Win2K. In the Python tutorial it says that typing \n
>> in string literals is the new-line character. I open the interpreter
>> and type a string with a \n in it but instead of outputting a string
>> with a new line, it outputs the \n as literal characters of the
>> string. Is the tutorial wrong, is the interpreter broken, or what is
>> happening ?
>>
>
> What exactly are you entering and what is output?
>
> Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)]
> on win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> "now\nis\nthe\ntime"
> 'now\nis\nthe\ntime'
>>>> print "now\nis\nthe\ntime"
> now
> is
> the
> time

Right you are and my faux pas. I didn't notice the print statement in the
tutorial.





More information about the Python-list mailing list