GoConqr has a new look! Let us know what you think.

Module 11 of 20 · Text

The print() function - the escape and newline characters 1

David Khieu

The print() function - the escape and newline characters

We've modified the code again. Look at it carefully. 

There are two very subtle changes - we've inserted a strange pair of characters inside the rhyme. They look like this: \n. 

Interestingly, while you can see two characters, Python sees one. 

the backslash (\_ has a very special meaning when used inside strings - this is called the escape character.

The word escape should be understood specifically - it means that the series of characters in the string escapes for the moment (a very short moment) to introduce a special inclusion. 

In other words, the backslash doesn't mean anything in itself, but is only a kind of announcement, that the next character after the backslash has a different meaning too. 

The letter n placed after the backslash comes from the word newline.

Both the backslash and the n form a special symbol named a newline character, which urges the console to start a new output line

Run the code. Your console should now look like this: 

As you can see, two newlines appear in the nursery rhyme, the places where the \n have been used. 

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?