use of \n | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

use of \n

I entered "Hello\nWorld" to go to a new line using IDLE Python 3.5.2 Shell. All I got after pressing enter was 'Hello\nWorld'. What did I do wrong?

6th Jan 2017, 7:19 PM
George Kanellopoulos
George Kanellopoulos - avatar
3 Answers
+ 3
Oh basicly when program see this go to the next line... simple as that
6th Jan 2017, 10:37 PM
Mark
Mark - avatar
0
the compiler is reading it as a whole string. if you're trying to use an end line try splitting it up your output. so output "Hello" '\n' "World". I'm not super-familiar with python, but usually '\n' is treated as a single character, not a string (like when you say "\n", the computer outputs exactly what you say within the quotation marks).
6th Jan 2017, 7:28 PM
Ethan
0
try. ("Hello \n world")
6th Jan 2017, 10:08 PM
Code Freak
Code Freak - avatar