split() String Method in Python with Examples

split() String Method Syntax

split(self, /, sep=None, maxsplit=-1)

split() returns a list of the words in the string, using sep as the delimiter string.

sep: The delimiter according which to split the string. None (the default value) means split according to any whitespace, and discard empty strings from the result.

maxsplit: Maximum number of splits to do. -1 (the default value) means no limit.

Example: split() String Method

message = 'Welcome to python'

splitted = message.split(' ')



<class 'list'>
['Welcome', 'to', 'python']

Related String Methods