The str.split() method without an argument splits on whitespace:

>>> "many   fancy word \nhello    \thi".split()
['many', 'fancy', 'word', 'hello', 'hi']
Answer from Sven Marnach on Stack Overflow
🌐
W3Schools
w3schools.com › python › ref_string_split.asp
Python String split() Method
Remove List Duplicates Reverse a String Add Two Numbers · Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Training ... The split() method splits a string into a list.
Discussions

Split string by single space only and ignore multiple space?
import re re.split(r'\b\s\b',s) I am not a regular expressions expert, but I think this is what you are talking about More on reddit.com
🌐 r/learnpython
18
5
March 23, 2020
Split string at a space or "," in python
How can I split a string at a space or at a comma? I want it to do something like this: list=input.split(" " or ",") More on linustechtips.com
🌐 linustechtips.com
2
March 28, 2025
Split string at a space or ","
Use regex, regular expressions. For exmample, import re data = "123 456,789 ABC,DEF GHI" parts = re.split(r'[,\s]+', data) # splits on comma or space print(parts) More on reddit.com
🌐 r/PythonLearning
4
2
March 27, 2025
split() function splitting every character?
You call c.split() but don't do anything with the result. c continues to refer to the original, unsplit, string; so c[0] gives you the first character of that string. You possibly mean c = c.split(), but it would be better to assign it to a new variable. More on reddit.com
🌐 r/learnpython
20
44
April 27, 2022
🌐
Enki
enki.com › post › how-to-split-strings-in-python
Enki | Blog - How to Split Strings in Python
The split() method is a built-in function for separating strings using a specified delimiter. Parameter: By default, split() uses a space character (' ') as the delimiter.
🌐
Reddit
reddit.com › r/learnpython › split string by single space only and ignore multiple space?
r/learnpython on Reddit: Split string by single space only and ignore multiple space?
March 23, 2020 -

Let's say I have a string like s = 'This string has double spaces or more in it.\n What to do'

I would like to split it so it becomes ['This', 'string has', 'double spaces', 'or', 'more', 'in', 'it.\n', 'What', 'to', 'do']

How can I ignore multiple spaces and split them as one word?

🌐
GeeksforGeeks
geeksforgeeks.org › python › python-string-split-including-spaces
Python - String Split including spaces - GeeksforGeeks
July 11, 2025 - import re s = "Hello World Python" # Split the string including spaces res = re.split(r"(\s+)", s) print(res) ... By wrapping \s+ in parentheses, we ensure spaces are captured as separate elements.
🌐
Mimo
mimo.org › glossary › python › string-split-method
Learn Python's String Split Method, Simplify Text Processing
Default Separator is Whitespace: If you call .split() with no arguments, it will split the string by any sequence of whitespace (spaces, newlines, tabs) and discard empty strings. Does Not Modify the Original String: .split() is non-destructive. It returns a new list and leaves the original ...
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-string-split
Python split() Method - GeeksforGeeks
4 weeks ago - Explanation: string contains multiple spaces between "Hello" and "world" and split() automatically treats consecutive spaces as a single separator. By default, split() uses whitespace as the separator.
🌐
Real Python
realpython.com › python-split-string
How to Split a String in Python – Real Python
November 4, 2024 - You split a string by spaces in Python using .split() without arguments.
🌐
Medium
medium.com › @huasa0115 › python-how-to-use-string-split-method-ee77458839d8
[Python] How to use String split() method? | by Yi-Ning Huang | Medium
July 16, 2025 - If we do not specify the separator, by default, any whitespace is a separator. It splits on any sequence of whitespace characters (spaces, tabs, newlines) and it automatically removes leading/ trailing whitespaces. Extra spaces between words are treated as one separator. ... Data & Analytics Engineer in US healthcare. Writing about SQL, Python...
🌐
Linus Tech Tips
linustechtips.com › software › programming
Split string at a space or "," in python - Programming - Linus Tech Tips
March 28, 2025 - By ff_Floris March 27, 2025 in Programming · python · Share · https://linustechtips.com/topic/1606909-split-string-at-a-space-or-in-python/ More sharing options... Followers 1 · Go to solution Solved by Slottr, March 27, 2025 · You would use regex, like this: import re mystring = input() re.split(r'[\s,]+', mystring) You need to be a member in order to leave a comment ·
🌐
Vultr Docs
docs.vultr.com › python › standard-library › str › split
Python str split() - Split String | Vultr Docs
December 11, 2024 - Use split() without any arguments, which defaults to splitting the string by whitespace. ... Here, split() divides the string text into words using spaces as the default separator.
🌐
Quora
quora.com › In-Python-how-do-I-split-a-string-by-whitespace-and-then-assign-each-word-to-a-new-variable
In Python, how do I split a string by whitespace and then assign each word to a new variable? - Quora
Answer (1 of 8): You can use the string method split() to split on whitespace and Python 3’s unpack operator to easily deal with the rest since you are unlikely to know the number of words in the string: [code]>>> string = input('Enter first and last name, followed by stuff: ') Enter first ...
🌐
Great Learning
mygreatlearning.com › blog › it/software development › python string split() method
Python String split() Method
June 28, 2023 - The split() method is used to break up a string into a list of substrings based on a specified delimiter. By default, it splits the string by whitespace, but you can specify any delimiter, such as a comma, semicolon, or custom character.
🌐
Simplilearn
simplilearn.com › home › resources › software development › python split() function: how to use split() in python
Python split() Function: Syntax, and Usage Guide
July 31, 2025 - The split() function in Python can be used to split a given string or a line by specifying one of the substrings of the given string as the delimiter.
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
freeCodeCamp
freecodecamp.org › news › how-to-split-a-string-in-python
Python .split() – Splitting a String in Python
September 8, 2022 - When this is the case, the .split() method treats any consecutive spaces as if they are one single whitespace. As you saw earlier, when there is no separator argument, the default value for it is whitespace.
🌐
Tutorialspoint
tutorialspoint.com › python › string_split.htm
Python String split() Method
The Python String split() method splits all the words in a string separated by a specified separator. This separator is a delimiter string, and can be a comma, full-stop, space character or any other character used to separate strings.
🌐
Note.nkmk.me
note.nkmk.me › home › python
Split a String in Python (Delimiter, Line Breaks, Regex) | note.nkmk.me
May 4, 2025 - ... Use the split() method to split a string using a specified delimiter. ... If no argument is provided, the string is split using whitespace (spaces, newlines \n, tabs \t, etc.), treating consecutive whitespace characters as a single delimiter.
🌐
Index.dev
index.dev › blog › how-to-split-strings-in-python
5 Best Ways to Split a String in Python [+Examples]
split() function in Python offers a quick and effective approach for breaking strings. Split() by default breaks a string by any whitespace—including spaces, tabs, or newlines.
🌐
Python
docs.python.org › 3 › library › string.html
string — Common string operations
string.capwords(s, sep=None)¶ · Split the argument into words using str.split(), capitalize each word using str.capitalize(), and join the capitalized words using str.join(). If the optional second argument sep is absent or None, runs of whitespace characters are replaced by a single space and leading and trailing whitespace are removed...