On Fri, Aug 3, 2012 at 1:40 PM, Jerry Hill <malaclyp...@gmail.com> wrote:
> On Fri, Aug 3, 2012 at 4:18 PM, Alexander Q. <alexxqu...@gmail.com> wrote: > > I'm following the tutorial from python.org > > (http://docs.python.org/tutorial/introduction.html) and am having a few > > indiscrepancies regarding the new line command. > > > > The tutorial says that this code > > > > hello = "This is a rather long string containing\n\ > > several lines of text just as you would do in C.\n\ > > Note that whitespace at the beginning of the line is\ > > significant." > > > > should yield this output: > > > > This is a rather long string containing > > several lines of text just as you would do in C. > > Note that whitespace at the beginning of the line is significant. > > You left out the other line of code in the tutorial, which says you > need to do print(hello) to the the output that is described. Did you > do that? If so, it should work fine. If not, what did you do > instead? If you just typed: > > >>>hello > > at the interpreter prompt, then you are actually seeing the equivalent > of print(repr(hello)), instead of print(hello). > > Can you copy and paste your session for us? > > Jerry > That was it Jerry- when I typed in "print hello" instead of just "hello", the output was exactly like the one in the tutorial. Alternatively, I could accomplish the same type of output by using triple quotes around the same text, except that I would have to format it manually if I want it to come out looking the same way as it did when using "\n" in the previous example? Thanks again for your help. The way I understand it from your explanation is that "hello" does a literal output of everything typed without processing the escape backslashes, while "print hello" does process them. -Alex
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor