Function Details: rpartition

Description


Partition the string into three parts using the given separator.


Extended Description


The rpartition() method searches for the last occurrence of the separator in the string and returns a tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, it returns a tuple containing two empty strings and the entire original string.


Exceptions


  • ValueError: If the separator is an empty string

Read More about rpartition from Python Documentation

Function Signature



Module: builtins

Class: str

Parameters



Parameter List


  • sep: str

Return


Returns a tuple of three strings: (head, separator, tail)


Return Type


Tuple[str, str, str]

Output

Explanation

Basic usage of rpartition() to split the string at the last comma.