- split() can select the position in a string from the front to divide.
- rsplit() can select the position in a string from the back to divide.
test = "1--2--3--4--5"
print(test.split("--", 2)) # Here
print(test.rsplit("--", 2)) # Here
Output:
['1', '2', '3--4--5'] # split()
['1--2--3', '4', '5'] # rsplit()
In addition, if split() and rsplit() have no arguments as shown below:
test = "1 2 3 4 5"
print(test.split()) # No arguments
print(test.rsplit()) # No arguments
They can divide a string by one or more spaces as shown below:
['1', '2', '3', '4', '5'] # split()
['1', '2', '3', '4', '5'] # rsplit()
Answer from Super Kai - Kazuya Ito on Stack OverflowW3Schools
w3schools.com โบ python โบ ref_string_rsplit.asp
Python String rsplit() Method
Python Examples Python Compiler ... Plan Python Interview Q&A Python Training ... The rsplit() method splits a string into a list, starting from the right....
Pandas
pandas.pydata.org โบ docs โบ reference โบ api โบ pandas.Series.str.rsplit.html
pandas.Series.str.rsplit โ pandas 3.0.5 documentation
>>> s.str.split(expand=True) 0 1 2 3 4 0 this is a regular sentence 1 https://docs.python.org/3/tutorial/index.html NaN NaN NaN NaN 2 NaN NaN NaN NaN NaN ยท For slightly more complex use cases like splitting the html document name from a url, a combination of parameter settings can be used. >>> s.str.rsplit("/", n=1, expand=True) 0 1 0 this is a regular sentence NaN 1 https://docs.python.org/3/tutorial index.html 2 NaN NaN
21:19
split(), rsplit(), join() methods in python | string manipulation ...
04:47
split function in Python | rsplit function | string function - YouTube
02:52
Python rsplit() string method - YouTube
09:57
Lear python programming [HackerRank] | split | rsplit | string ...
Python Strings rsplit() Method Explained #python #shorts ...
Top answer 1 of 2
10
- split() can select the position in a string from the front to divide.
- rsplit() can select the position in a string from the back to divide.
test = "1--2--3--4--5"
print(test.split("--", 2)) # Here
print(test.rsplit("--", 2)) # Here
Output:
['1', '2', '3--4--5'] # split()
['1--2--3', '4', '5'] # rsplit()
In addition, if split() and rsplit() have no arguments as shown below:
test = "1 2 3 4 5"
print(test.split()) # No arguments
print(test.rsplit()) # No arguments
They can divide a string by one or more spaces as shown below:
['1', '2', '3', '4', '5'] # split()
['1', '2', '3', '4', '5'] # rsplit()
2 of 2
1
The difference between split and rsplit is pronounced only if the maxsplit parameter is given. In this case the function split returns at most maxsplit splits from the left while rsplit returns at most maxsplit splits from the right.
Both functions work on python string (str) type, and their signatures are:
str.split(sep=None, maxsplit=-1)
str.rsplit(sep=None, maxsplit=-1)
A common use of rsplit is to get the folder from a full filepath, for example:
filepath = '/home/user/file.txt'
folder = filepath.rsplit('/',1)[0] # /home/user
Reference: python docs
Codecademy
codecademy.com โบ docs โบ python โบ strings โบ .rsplit()
Python | Strings | .rsplit() | Codecademy
October 7, 2023 - The .rsplit() method in Python is a string method that splits a string into a list of substrings from the right end of the string based on a specified delimiter.
Python Reference
python-reference.readthedocs.io โบ en โบ latest โบ docs โบ str โบ rsplit.html
rsplit โ Python Reference (The Right Way) 0.1 documentation
Returns a list of the words in the string, separated by the delimiter string (starting from right) ยท str. rsplit([sep[, maxsplit]])
Jobtensor
jobtensor.com โบ Tutorial โบ Python โบ en โบ String-Methods-rsplit
Python String rsplit(), Definition, Syntax, Parameters, Examples | jobtensor
The rsplit() method splits a string into a list, starting from the right. If no "maxsplit" is specified, this method will return the same as the split() method.
Programiz
programiz.com โบ python-programming โบ methods โบ string โบ rsplit
Python String rsplit()
rsplit() breaks the string at the separator starting from the right and returns a list of strings.
Tutorialspoint
tutorialspoint.com โบ python โบ rsplit_method.htm
Python String rsplit() Method
If we does not provide any delimiter, the rsplit() method splits the string based on whitespace characters by default.
CodeSignal
codesignal.com โบ learn โบ courses โบ string-manipulation-for-python-coders โบ lessons โบ mastering-text-analysis-with-python-splitting-and-joining-strings-like-a-pro
Mastering Text Analysis with Python: Splitting and Joining ...
In addition to split(), Python provides other methods like splitlines() and rsplit() for specialized splitting.
GeeksforGeeks
geeksforgeeks.org โบ python โบ python-pandas-reverse-split-strings-into-two-list-columns-using-str-rsplit
Python | Pandas Reverse split strings into two List/Columns using str.rsplit() - GeeksforGeeks
July 11, 2025 - Example #1: Splitting string from right side into list In this example, the string in the Team column is split at every occurrence of "t". n parameter is kept 1, hence the max number of splits in the same string is 1. Since rsplit() is used, the string will be separated from the right side.
Educative
educative.io โบ answers โบ what-is-the-numpycharrsplit-function-in-python
What is the numpy.char.rsplit() function in Python?
The numpy.char.rsplit() function in Python is used to return a list of words in the string of an array of strings using a sep as the delimiter string.