Splitting the Lines
If we are working with text, most likely it will contain more than 1 line. And it would be great if we could split such string into lines.
One way to do it is to use .split
method from the previous chapter with escape character \n
as an argument (this one makes a line break). But Python provides us with a special function, that makes it - .splitlines
. This function has only one optional argument keeplinebreaks
(bool) that specifies if the line breaks should be included (if True), or shouldn't (if False, by default).
Swipe to start coding
Given multiline string zen
with the first 6 principles The Zen of Python, by Tim Peters. Split this string by lines (without printing the escape characters).
Oplossing
Bedankt voor je feedback!
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Vat dit hoofdstuk samen
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 4.35
Splitting the Lines
Veeg om het menu te tonen
If we are working with text, most likely it will contain more than 1 line. And it would be great if we could split such string into lines.
One way to do it is to use .split
method from the previous chapter with escape character \n
as an argument (this one makes a line break). But Python provides us with a special function, that makes it - .splitlines
. This function has only one optional argument keeplinebreaks
(bool) that specifies if the line breaks should be included (if True), or shouldn't (if False, by default).
Swipe to start coding
Given multiline string zen
with the first 6 principles The Zen of Python, by Tim Peters. Split this string by lines (without printing the escape characters).
Oplossing
Bedankt voor je feedback!
Awesome!
Completion rate improved to 4.35single