Skip to content
String Methods

rsplit()

Split text into a list, starting from the right when a limit is used.

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

Split text into a list, starting from the right when a limit is used.

Parameters

NameDescription
sepThe separator to split on; if omitted, whitespace is used.
maxsplitMaximum number of splits; -1 means no limit.

Returns

A list of pieces from the string.

Try it

Run it and change it
text = "a,b,c"
print(text.rsplit(",", 1))

Worth knowing

  • With a maxsplit limit, rsplit() keeps the left part together. split() applies the limit from the left instead.

Related entries