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
1227
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 Bootcamp Python Training ... The split() method splits a string into a list.
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
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
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() 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
04:52
How To Split String Using Delimiter In Python - YouTube
01:49
The string "split" method in Python - YouTube
08:04
🐍 Python Tutorial #27: Splitting and Joining Strings - YouTube
07:39
Python String Splitting: String Basics & Using the .split() Method: ...
06:32
How to Split string on whitespace in Python - YouTube
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?
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 ...
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.
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 ·
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
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.
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...
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.