split string method in Python

The split() method splits a string into a list.
You can specify the separator, default separator is any whitespace.
When maxsplit is specified, the list will contain the specified number of elements plus one.
Example 1:

str = " a number of   words"
print(str.split())
Output 1:
['a', 'number', 'of', 'words']
Example 2:
str = "-a-number-of------words"
print(str.split('-'))
Output 2:
['', 'a', 'number', 'of', '', '', '', '', '', 'words']
Example 3:
str = "-a-number-of------words"
print(str.split('-',3))
Output 3:
['', 'a', 'number', 'of------words']