PyDocs

Nav

Python Runtime Services

str.rpartition

builtins

method of str
  • str.rpartition(sep, /)
Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the
end.  If the separator is found, returns a 3-tuple containing the
part before the separator, the separator itself, and the part after
it.

If the separator is not found, returns a 3-tuple containing two
empty strings and the original string.
1 Example
>>> 'Monty Python'.rpartition(' ')
('Monty', ' ', 'Python')
>>> "Monty Python's Flying Circus".rpartition(' ')
("Monty Python's Flying", ' ', 'Circus')
>>> 'Monty Python'.rpartition('-')
('', '', 'Monty Python')
from the Python docs
See Also
No see-alsos for builtins/str.rpartition
0 Notes
No notes for str.rpartition