Python Split Exercises

Let’s check out some exercises that will help understand .split() method better.

Exercise 3-a: Splitting Up Words Using Split Method

Split the string based on space character: " ".


.split() method can be used to split strings based on a given character. It returns a list of split substrings.

lst = str.split(" ")

 

Exercise 3-b: Splitting up based on a specific character (:) with split method

Split the numbers.


.split() method can be used to split strings based on a given character. It returns a list of split substrings.

lst = str.split(":")