Hello Ava/Ashley On 4 December 2010 01:47, Ashley Blackwell <georgeandsnickerdoo...@gmail.com > wrote:
> Exactly what is a newline character? Not all characters used to encode information are printable/displayable characters like the letters in the alphabet or numerals or punctuation and symbols. There's several "special" characters that have special meanings and represent other things. A "newline character" is such a character. It is character 13 in the ASCII character set (which is a well known encoding standard that define a mapping between bytes of data and characters. See here: http://www.asciitable.com/ ) It's meaning is "start a new line" instead of encoding "a" or "z" or "#" or whatever. > 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" ". > So, what this is trying to explain is that by default Python appends a newline character to the end of whatever it's been told to print. This has the effect of normally puttig successive print statements on successive lines. However, you can override this behaviour and tell Python to use another character as its "end" character to append to whatever is printed, by specifying the "end" parameter. If you for example replace this with space e.g. " " then as you can see when you execute the 2 print statements they end up on one line, seperated by thace space, instead of being on 2 seperate lines. Does that help? Walter
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor