Python String split() Method

From time to time, you will find yourself trying to get a list of things from a string. For this purpose, you can use the split() function.

How to use Python split function

The first split function parameter is a separator, character on which the division of string will be happening. If the split function has an empty separator character, whitespace will be used as default splitting character. Let’s look at the example:

We can use also custom string as splitting string:

What I personally consider the greatest plus of Python split method is actually a possibility to directly assign split string parts into the variable. Here is a nice example:

Splitting the string is opposite of concatenation. If you want to concatenate the strings, check the guide how to concatenate the strings in the best way.