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 Top answer 1 of 4
1228
The str.split() method without an argument splits on whitespace:
>>> "many fancy word \nhello \thi".split()
['many', 'fancy', 'word', 'hello', 'hi']
2 of 4
94
import re
s = "many fancy word \nhello \thi"
re.split('\s+', s)
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 Training ... The split() method splits a string into a list.
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
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
Using Split only on the first occurrence of a character?
Why not just split with (.) , grab the last two fields; contoso and com ...then join the two with a dot when you're all done? This covers FQDN that might have multiple subdomains too, fwiw. $var.Split(".")[-2,-1] -join "." #this gives you "contoso.com" More on reddit.com
Splitting a string but would like everything in double quotes to not be split say by space
text.split("\\B") does it for me More on reddit.com
08:04
๐ Python Tutorial #27: Splitting and Joining Strings - YouTube
01:49
The string "split" method in Python - YouTube
04:52
How To Split String Using Delimiter In Python - YouTube
07:39
Python String Splitting: String Basics & Using the .split() Method: ...
12:04
How To Split A String In Python - YouTube
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?
Python Examples
pythonexamples.org โบ python-split-string-by-space
How to Split String by Space in Python?
import re str = '63 41 92 81 69 70' #split string by single space chunks = re.split(' +', str) print(chunks)
GeeksforGeeks
geeksforgeeks.org โบ python โบ python-string-split
Python split() Method - GeeksforGeeks
July 1, 2026 - 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.
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.
Python Guides
pythonguides.com โบ python-split-string-by-space
Print Characters in a String Separated by Space in Python
September 15, 2025 - The end=โ โ part ensures that Python does not insert a newline after each character but instead adds a space. Another clean and Pythonic way is to use the join() function. This is my personal favorite because itโs concise and very efficient for string manipulation.
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, PySpark, and the healthcare meaning behind the data.
Finxter
blog.finxter.com โบ python-split-string-space
Python | Split String Space โ Be on the Right Side of Change
December 6, 2022 - โญSummary: Use "given string".split(' ') to split the given string by space and store each word as an individual item in a list.
Reddit
reddit.com โบ r/pythonlearning โบ split string at a space or ","
r/PythonLearning on Reddit: Split string at a space or ","
March 27, 2025 -
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 ",")
Top answer 1 of 2
1
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)
2 of 2
1
You can use the Regex (or "Re") module for a more feature-laden split command. You can use this syntax: import re. re.split(r"[,\s]+", mystring: str) The ,\s part shows the characters to split with, that is, either a comma or a space (which the \s stands for). Or you could simply re-split the results after splitting with a space or comma and then .join the results from both.
freeCodeCamp
freecodecamp.org โบ news โบ how-to-split-a-string-in-python
Python .split() โ Splitting a String in Python
September 8, 2022 - In the example above, each time .split() encountered a space character, it split the word and added the empty space as a list item. When there is no maxsplit argument, there is no specified limit for when the splitting should stop. In the first example of the previous section, .split() split the string each and every time it encountered the separator until it reached the end of the string.
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.
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 ...
Finxter
blog.finxter.com โบ home โบ learn python blog โบ python | split string variable spaces
Python | Split String Variable Spaces - Be on the Right Side of Change
December 6, 2022 - Approach: You can use the filter() method to split the string by space. Feed in None as the first argument and the list of split strings as the second argument into the filter function. The filter() function then iterates through the list and filters out the spaces from the given string and ...