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

Course Content

String Manipulation in Python

SplittingSplitting

One more possible task is to split the string into separate words or into separate sentences.

Surely, Python can deal with that. Use .split method with separator as an argument (space by default). It will return a list of splits. This function also has the second argument maxsplit defining the number of splits to do (by default - maximum possible). For example,

By default, this method works from left to right. Like for .strip method, there is .rsplit method that works from right to left.

Task

Given string libraries. Split it into the list by comma as the separator (as in example).

Everything was clear?

Section 2. Chapter 4
toggle bottom row
course content

Course Content

String Manipulation in Python

SplittingSplitting

One more possible task is to split the string into separate words or into separate sentences.

Surely, Python can deal with that. Use .split method with separator as an argument (space by default). It will return a list of splits. This function also has the second argument maxsplit defining the number of splits to do (by default - maximum possible). For example,

By default, this method works from left to right. Like for .strip method, there is .rsplit method that works from right to left.

Task

Given string libraries. Split it into the list by comma as the separator (as in example).

Everything was clear?

Section 2. Chapter 4
toggle bottom row
some-alt