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.
Arguments
Parameters
| Name | Description |
|---|---|
| sep | The separator text to find; it cannot be empty. |
Result
Returns
A three-item tuple: text before the separator, the separator, and text after it.
Run it
Try it
Run it and change it
text = "name=value"
print(text.rpartition("=")) Output
Press Run to see what it prints.Worth knowing
rpartition()uses the last separator, whilepartition()uses the first. Both always return three items.