+ 2

Why woudk I want a \n on my output?

14th Jun 2019, 7:47 AM
dorjee wangchuk
dorjee wangchuk - avatar
5 Respostas
+ 4
\n won't be visible like this. print('Hello\nWorld') ... will turn into this output: Hello World
14th Jun 2019, 11:16 AM
HonFu
HonFu - avatar
+ 3
Hello! I will shortly introduce 2 popular programming languages. Python: Very powerful programming language in data science. JavaScript: Very powerful as web frontend programming language. Without \n the same text would be like this: Hello! I will shortly introduce 2 popular programming languages. Python: Very powerful programming language in data science. JavaScript: Very powerful as web frontend programming language. \n represents a newline. Using newlines vicely increases readability of long texts.
14th Jun 2019, 7:58 AM
Seb TheS
Seb TheS - avatar
+ 2
dorjee wangchuk \n are reserved word for (N)ew line. Interpreter find first symbol - in this case that was be \ (backslash) and expect (by default) that next letter was predefined. In short, \n is "NEW LINE".
14th Jun 2019, 1:12 PM
Aleksandar Nedeljkovic
Aleksandar Nedeljkovic - avatar
+ 1
so that it looks good
14th Jun 2019, 7:55 AM
Cat Sauce
Cat Sauce - avatar
+ 1
By the way, "Hello \n World!" was display: Hello World! without white space.
14th Jun 2019, 1:13 PM
Aleksandar Nedeljkovic
Aleksandar Nedeljkovic - avatar