Skip to content
String Methods

rpartition()

Split text once at the last separator and keep the separator in the result.

str.rpartition(sep)

Split text once at the last separator and keep the separator in the result.

Parameters

NameDescription
sepThe separator text to find; it cannot be empty.

Returns

A three-item tuple: text before the separator, the separator, and text after it.

Try it

Run it and change it
text = "name=value"
print(text.rpartition("="))

Worth knowing

  • rpartition() uses the last separator, while partition() uses the first. Both always return three items.

Related entries