split()

A string method that cuts a string into a list of parts, at white space by default or at a separator you give.

In more detail

"a b c".split() gives ["a", "b", "c"], ignoring runs of spaces; "a,b,,c".split(",") gives ["a", "b", "", "c"], keeping the empty piece. For real comma-separated files use the csv module, which also handles quoted commas.

Example

"to be or not".split()

Related terms

Taught in

References