Home / Python / Reference / String methods

Python string rsplit() method

Like split, but counts the cuts from the right.

Syntax

str.rsplit(sep=None, maxsplit=-1)

Only different from split when you give maxsplit.

Parameters

sepwhere to cut
maxsplitthe most cuts, counted from the right

Return value

list

Example

Code

print("archive.2026.tar.gz".rsplit(".", 1))
print("a b c d".rsplit(maxsplit=2))

Output

['archive.2026.tar', 'gz']
['a b', 'c', 'd']

Related

Learn it step by step in the free lesson Strings, with exercises that check your answers.