Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Splitting the Lines | String Methods
String Manipulation in Python
course content

Зміст курсу

String Manipulation in Python

String Manipulation in Python

1. Basic Concepts
2. String Methods
3. Strings Formatting

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).

Завдання

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).

Завдання

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).

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 2. Розділ 5
toggle bottom row

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).

Завдання

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).

Завдання

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).

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 2. Розділ 5
toggle bottom row

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).

Завдання

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).

Завдання

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).

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

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).

Завдання

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).

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 2. Розділ 5
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt