+ 1
Please how does the \n work
2 ответов
+ 4
\n is used for breaking into a new line.
consider these two Python codes.
print("Hello World")
print("Hello\nWorld")
Outputs
=======
1st= Hello World
2nd= Hello
World
As you can see, the first one printed normally.
But the second one printed in two lines. It printed Hello, then when it got to \n, it moved to a new line, and printed World
+ 5
Edozie Onyeanusi '\n' represent the new line character. Because some characters have not an easy representation (like newline, tabulation etc) someone decided to represent them by escape with a backslash character followed by one character (in our case \n).