🌐
Reddit
reddit.com › r/learnpython › how to split each string into words and collects all words in a new list.
r/learnpython on Reddit: How to split each string into words and collects all words in a new list.
May 9, 2021 -

I'm working on a book I've downloaded from project Guttenberg and after doing some data cleaning I have ended up with a list of strings. Next I should split each string into words and collect all the words in a new list.

I have tried to use the split commando but somehow I end up with transforming each string into a list instead of a a string.

I'm sorry if I'm being vague. Please let me know if I should provide more infromation...

I have created the following function.

def splitter():

wordList = [s.split(" ") for s in book]

return wordList

book = splitter()

Somehow I end up with the following output when I type book[0] into the console:

['the',

'history',

'of',

'australian',

'exploration',

'from',

'1788',

'to',

'1888']

Instead of splitting the string and ending up with a list of strings I have created a list of lists.

What I want to end up with is:

In[] book[0]

Out[] the

and

in[] book[:9]

['the',

'history',

'of',

'australian',

'exploration',

'from',

'1788',

'to',

'1888']

Discussions

python - Converting a String to a List of Words? - Stack Overflow
I'm trying to convert a string to a list of words using python. I want to take something like the following: string = 'This is a string, with words!' Then convert to something like this : list = ... More on stackoverflow.com
🌐 stackoverflow.com
Is there a function in python to split a word into a list? - Stack Overflow
Is there a function in python to split a word into a list of single letters? e.g: s = "Word to Split" to get wordlist = ['W', 'o', 'r', 'd', ' ', 't', 'o', ' ', 'S', 'p', 'l', 'i', 't'] More on stackoverflow.com
🌐 stackoverflow.com
Python split string with a list of words - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
🌐 stackoverflow.com
How to split each string into words and collects all words in a new list.
string.split() return a list or words, so if you put [s.split()] it would return a list of lists. i would try something like this: new_list = [] for line in book: for word in line.split(' '): new_list.append(word) More on reddit.com
🌐 r/learnpython
6
4
May 9, 2021
🌐
Sentry
sentry.io › sentry answers › python › split a string into a list of words in python
Split a string into a list of words in Python | Sentry
June 15, 2024 - sentence = 'Jackdaws love my big sphinx of quartz.' wordlist = sentence.split() print(wordlist) # will print ['Jackdaws', 'love', 'my', 'big', 'sphinx', 'of', 'quartz.'] The split method takes an optional sep argument, allowing us to specify a substring to treat as the separator between items in our list. If no separator is specified, as in the above example, the string is split on each run of one or more whitespace characters (spaces, tabs, and newlines). Splitting the string on whitespace characters preserves sentence punctuation such as periods and commas, like quartz.
🌐
W3Schools
w3schools.com › python › ref_string_split.asp
Python String split() Method
Q&A Python Training ... The split() method splits a string into a list. You can specify the separator, default separator is any whitespace. Note: When maxsplit is specified, the list will contain the specified number of elements plus ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-spilt-a-sentence-into-list-of-words
Split a sentence into list of words in Python - GeeksforGeeks
July 11, 2025 - import re s = "This is! a sentence, with: punctuation." # Split the sentence using regex to keep only words words = re.findall(r'\b\w+\b', s) print(words)
🌐
LabEx
labex.io › tutorials › python-how-to-split-a-string-into-a-list-of-words-in-python-415131
How to split a string into a list of words in Python | LabEx
Python is a versatile programming language that offers a wide range of tools and techniques for working with strings. One of the most common tasks in Python is splitting a string into a list of words, which is essential for text processing, data analysis, and various other applications.
🌐
Techie Delight
techiedelight.com › home › python › split a string into a python list
Split a string into a Python list | Techie Delight
July 7, 2026 - Convert a string to a list of ... the string to the list constructor: Download Run Code · You can use the str.split(sep=None) function, which returns a list of the words in the string, using sep as the delimiter ...
🌐
W3docs
w3docs.com › python
How do I split a string into a list of words?
Alternatively, you can use the re module to split a string using a regular expression. Here is an example that uses the re.split() function to split a string into a list of words:
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-convert-a-string-to-a-list-of-words-in-python
How to convert a string to a list of words in python?
March 24, 2026 - If we use the split() method without any arguments, it splits the string at every whitespace character and returns a list where each element is a word from the original string. Following is the syntax of the Python str.split() method −
🌐
freeCodeCamp
freecodecamp.org › news › python-split-string-how-to-split-a-string-into-a-list-or-array-in-python
Python Split String – How to Split a String into a List or Array in Python
April 4, 2023 - This method is available for any string object in Python and splits the string into a list of substrings based on a specified delimiter. So here's an overview of these methods and when to use each one for quick reference: split(): This is the most common method for splitting a text into a list. You can use this method when you want to split the text into words or substrings based on a specific delimiter, such as a space, comma, or tab.
🌐
Python Guides
pythonguides.com › how-to-split-a-sentence-into-a-list-of-words-in-python
How To Split A Sentence Into Words In Python?
October 31, 2024 - Check out Split a String into Equal Parts in Python · To handle extra spaces or clean up the resulting list, you can combine split() with list comprehension. Here is an example. sentence = "John lives in New York, and works at Google." words = [word.strip(",.") for word in sentence.split()] print(words) ... This example strips punctuation from each word after splitting the sentence, providing a cleaner list of words.
🌐
Delft Stack
delftstack.com › home › howto › python › python split sentence into words
How to Split Sentence Into Words in Python | Delft Stack
February 2, 2024 - The str.split() function can be used to split a sentence into a list of words in Python.
🌐
DevGenius
blog.devgenius.io › transforming-strings-into-lists-2fdbbd697ad9
Transforming Strings into Lists. A guide to splitting in python | by A.I Hub | Dev Genius
December 24, 2024 - If we have a multiline string and ... the separator or we can use the splitlines method. The method splitlines() splits a multiline string into a list of single-line strings....
🌐
Medium
medium.com › analytics-vidhya › python-list-ii-48eefe298f01
Python List - II. Splitting a string into a list in… | by Deepa Mariam George | Analytics Vidhya | Medium
February 5, 2024 - my_text = ‘I am learning Python!’ words = my_text.split() #splits the text wherever there is a space. print(words) ... my_string = ‘abcd-efgh-ijkl’ my_list = my_string.split(‘-’) #split the text wherever there’s a hyphen(‘-') print(my_list)
🌐
Mimo
mimo.org › glossary › python › string-split-method
Learn Python's String Split Method, Simplify Text Processing
To split a string into a list of substrings, you use the built-in string method .split(). Its behavior depends on the arguments you provide. ... Become a Python developer.
🌐
University of Pittsburgh
sites.pitt.edu › ~naraehan › python3 › split_join.html
Python 3 Notes: Split and Join
Python 3 Notes [ HOME | LING 1330/2330 ] Splitting and Joining Strings <<Previous Note Next Note >> On this page: .split(), .join(), and list(). Splitting a Sentence into Words: .split() Below, mary is a single string. Even though it is a sentence, the words are not represented as discreet units.
🌐
YouTube
youtube.com › shorts › P9SxVjQLDb0
Split Words in a String into a List Using Python #shorts - YouTube
Learn how to split the words in a string into a list in this Python code example tutorial / guide.This is another short in a series of small Python code exam...
Published: September 6, 2025