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
| Name | Description |
|---|---|
| sep | The 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, whilepartition()uses the first. Both always return three items.