0

\n isnt creating a new line. For example the output would be a Hello \n World instead of Hello World

\n issue

10th May 2017, 10:33 PM
Lisa Quinn
Lisa Quinn - avatar
3 Respuestas
+ 6
If your purpose is to write: Hello World ... with a blank line in between, you have to put twice '\n': print("Hello\n\nWorld") ... as the first create a new line in meaning that cursor move down one line and most left, so it's ready to write on the next line. By outputing a second new line char, you move down the cursor one line more, leaving a blank line between previous writting and cursor... But you don't need them by this way: print("Hello") print() print("World") ... because at end of each string printed is added implicitly a new line character ^^ You can change this behaviour, by passing a second named parameter to the function: print("Hello",end='') print("World",end=":)") ... will output: HelloWorld:) ... and the next print() will occurs next on same line ;)
11th May 2017, 12:47 AM
visph
visph - avatar
+ 3
print("Hello\nWorld") this outputs: Hello World
11th May 2017, 12:19 AM
LordHill
LordHill - avatar
+ 2
Try... print('Hello' '\n' 'World') or... print('Hello\nWorld')
11th May 2017, 9:52 AM
Lium Goon
Lium Goon - avatar