[Tutor] Newline

Alex Hall mehgcap at gmail.com
Sat Dec 4 03:07:07 CET 2010


On 12/3/10, Ashley Blackwell <georgeandsnickerdoodle at gmail.com> wrote:
> Hello everybody, I'm new to the mailing list so I'm pretty sure I'll have
> lots of questions:)
That is what the list is for. :)
>
> It's a very basic question I have and everybody might look at this
> question and say, "Wow, she reallly doesn't get it?" But oh well. Here's my
> question: I'm in Chapter 2 of my Python Programming Third Editition book.
> I've gotten to the section of the chapter where it talks about a "newline
> character. Exactly what is a newline character? I keep reading the same
> section of the book and I'm just not really understanding. Here's the code
> that the book uses to explain the newline character:
>
> print("Here", end="  ")
> print("it is...")
>
> The book says that I can specify that a space be the final character printed
> instead of a newline. In the first print() statement I specify that a space
> be the final string printed. So the text "Here" appears but no newline
> character. The next print() statement prints the text "it is"..." right
> after the space following the final "e" in the "Here" text. You do it by
> passing a space to the end parameter of the print() function with the code
> end"  ".
>
> My Operating System is Windows 7 and the Python version is 3.1.3. That's it.
> Thanks to anybody who responds to my question.
A newline character is just a character telling the computer to move
to the next line. Understand that all characters, from basic letters
(a, b, c, ...) to strange characters that you never see are
represented by numbers. For example, the letter a is 97, b is 98, and
so on. A space character is 32. A newline has a number as well, since
it is, after all, just another character.

Instead of using numbers, though, Python (like most programming
languages) lets you use what I believe are called escape sequences
(someone correct me here). Basically, putting a backslash (\) followed
by a letter will sometimes represent a character. \t is tab, for
example. In this case, try passing \n to your function (remember to
put it in quotes, since it is still a string!) and see if that does
it. I hope this makes some sense.
>
> --
> *Ava Durand*
>


-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap at gmail.com; http://www.facebook.com/mehgcap


More information about the Tutor mailing list