Python – How to Split a String into a List of Words

listpythonsplitstringtext-segmentation

How do I split a sentence and store each word in a list? e.g.

"these are words"   ⟶   ["these", "are", "words"]

To split on other delimiters, see Split a string by a delimiter in python.

To split into individual characters, see How do I split a string into a list of characters?.

Best Answer

Given a string sentence, this stores each word in a list called words:

words = sentence.split()
Related Question