The syntax of rpartition() is:
string.rpartition(separator)
rpartition() Parameters()
rpartition() method takes a string parameter separator that separates the string at the last occurrence of it.
Return Value from rpartition()
rpartition() method returns a 3-tuple containing:
- the part before the separator, separator parameter, and the part after the separator if the separator parameter is found in the string
- two empty strings, followed by the string itself if the separator parameter is not found
Example: How rpartition() works?
Output
('Python ', 'is ', 'fun')
('', '', 'Python is fun')
('Python is fun, ', 'is', "n't it")