+ 1

Please how does the \n work

19th Jan 2019, 8:49 AM
Edozie Onyeanusi
Edozie Onyeanusi - avatar
2 Answers
+ 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
19th Jan 2019, 9:51 AM
Dlite
Dlite - avatar
+ 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).
19th Jan 2019, 9:10 AM
KrOW
KrOW - avatar