Escaping Newlines | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson

Escaping Newlines

Hello Everybody, So I'm working through the Python 3 tutorial and in regards to strings they talk about inputting "\n" to "Escape a Newline" and I'm not entirely sure what they mean by "escape newline" as well as the "\n". I understood it when putting in an apostrophe for example: print("It wasn\'t supposed to rain today." Thank you in advance for your help.

25th Dec 2016, 12:11 PM
2 Answers
+ 1
when using "\n" the sentence stop and continue in new line ___________________ print ("hello world! ") print ("hello","\n","world! ") output hello world! hello world! _____________________ for second question you can use " at the first and ' when you want in strings like this print ("what's wrong? ") but if you want use only ' do it like this print ('what\'s wrong?)
25th Dec 2016, 1:33 PM
Minovsky - avatar
Escaping newlines using \n simply means its going to take you on another line nothing else
29th Dec 2016, 7:31 AM
Vipin Patel
Vipin Patel - avatar