Function Details: split

Description

Returns a list of the words in the string, using sep as the delimiter string.

Extended Description

split is a Python string method that divides string into list of substrings based on delimiter. Belongs to string partitioning family with rsplit and partition. Works with strip for clean text processing and join for string reconstruction. Without arguments, splits on whitespace, treating consecutive whitespace as single delimiter. Optional maxsplit parameter limits number of splits. Commonly used in file processing, data parsing, and text analysis where structured text needs to be broken into components. Essential for parsing CSV data, processing text files, and tokenizing strings. Returns list of split strings preserving order.


Read More about split from Python Documentation

Function Signature



Module: builtins

Class: str

Parameters



Parameter List


  • sep: str
  • maxsplit: int

Input String

No Separator Given

Separator Given

Splits on ANY Whitespace
'Hello World' → ['Hello', 'World']

Separator Found
'apple,orange'.split(',') → ['apple', 'orange']

Separator Not Found
'apple'.split(',') → ['apple']

With maxsplit Parameter
'a,b,c'.split(',', 1) → ['a', 'b,c']

Empty Separator
'python'.split('')

ValueError:
empty separator

Return



Return Type


List[str]

Output

Explanation