How can introduce break line in Python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 12

How can introduce break line in Python?

EN: I am trying to make paragraphs for one of my codes, however, I don't know how to make it. I have tried even with several of "\n\n\n" and "print"... lol. Can be used break line in Python? Before searching on Google, I prefer ask to our programming community. This question is easy for most of you, but some of us are new programming (me, in this case). Thank you and greetings! _______________________________ SP: Estoy intentando hacer párrafos para uno de mis códigos, sin embargo, no sé cómo hacerlos. He intentado incluso con muchos "\n\n\n" y "print"... lol. ¿Se pueden usar saltos de línea en Python? Antes de buscar en Google, prefiero preguntar a nuestra comunidad de programadores. Esta pregunta es fácil para la mayoría, pero algunos de nosotros estamos aprendiendo a programar (yo, en este caso). ¡Gracias y saludos!

2nd Aug 2019, 2:24 PM
🔸< 𝙷 𝙴 𝚁 𝙼 𝙾 𝚂 >🔸
🔸< 𝙷 𝙴 𝚁 𝙼 𝙾 𝚂 >🔸 - avatar
11 Answers
+ 12
Oh, that's true. As I use "\n\n\n..." it can be multiplied. Thank you all for your answers. I like to learn other ways.
2nd Aug 2019, 5:06 PM
🔸< 𝙷 𝙴 𝚁 𝙼 𝙾 𝚂 >🔸
🔸< 𝙷 𝙴 𝚁 𝙼 𝙾 𝚂 >🔸 - avatar
+ 11
Oh. True too. 1) print () 2) print ("""aaa bbb""") Both works, but the second needs three ". Can't be used two or one. Great, thank you all for your help. I have learned different ways to insert a break line!
2nd Aug 2019, 5:25 PM
🔸< 𝙷 𝙴 𝚁 𝙼 𝙾 𝚂 >🔸
🔸< 𝙷 𝙴 𝚁 𝙼 𝙾 𝚂 >🔸 - avatar
+ 11
Ya, I think is more easy to break paragraphs: print (""" """) And look more consistent than '\n\n', for example.
4th Aug 2019, 4:34 AM
🔸< 𝙷 𝙴 𝚁 𝙼 𝙾 𝚂 >🔸
🔸< 𝙷 𝙴 𝚁 𝙼 𝙾 𝚂 >🔸 - avatar
+ 10
print ("This is a test") print ("of the text.") print ("\n\nBefore this line,\nmust be a break line.") I have wrote that code. But as I said in my first comment, I used "\n\n" and didn't work. However, now works. This is strange. Do you know other possibilities to make break lines? And thanks.
2nd Aug 2019, 4:56 PM
🔸< 𝙷 𝙴 𝚁 𝙼 𝙾 𝚂 >🔸
🔸< 𝙷 𝙴 𝚁 𝙼 𝙾 𝚂 >🔸 - avatar
+ 5
You can also use triple quotes, which will preserve all your new lines and blank lines, e.g.: print("""This is an example of using triple quotes. It can produce blank lines.""") output: This is an example of using triple quotes. It can produce blank lines.
4th Aug 2019, 4:26 AM
David Ashton
David Ashton - avatar
+ 4
Herlon Costa Did you try it? It didn't work for me 🤔
24th Aug 2019, 1:46 AM
David Ashton
David Ashton - avatar
+ 4
Thanks for your comment!
24th Aug 2019, 8:49 PM
🔸< 𝙷 𝙴 𝚁 𝙼 𝙾 𝚂 >🔸
🔸< 𝙷 𝙴 𝚁 𝙼 𝙾 𝚂 >🔸 - avatar
+ 2
If you need repetive newlines of a special size, you can do it like this: nxt3='\n'*3 nxt5='\n'*5 nxt10=nxt5*2 tab='\t' Then you can use it... print("some" + nxt3 + "text") print(nxt5 + "some" + nxt10 + "more" + nxt3 + tab + "text")
4th Aug 2019, 3:08 PM
Crash
Crash - avatar
+ 2
It ends up writing on the same line. Sorry! :(
24th Aug 2019, 10:35 AM
Herlon Costa
Herlon Costa - avatar
0
Try it this bro: print("Type text..." "Type text...") :)
23rd Aug 2019, 9:28 PM
Herlon Costa
Herlon Costa - avatar
0
Try it: print("""\ First line Second line Third line... """)
30th Oct 2019, 11:33 PM
Herlon Costa
Herlon Costa - avatar