Syntax :
string.rpartition (separator)
Parameters :
separator - separates the string at the first occurrence of it.
Return value:
- It returns the part of the string before the separator , the delimiter parameter itself and the part after the delimiter if a delimiter parameter is found in the string.
- It returns two blank lines followed by the given string if no delimiter is found in the string.
Exception :
If separator argument is not supplied, it will throw TypeError.
Code # 1:
|
Output:
(’Geeks @ for @ Geeks @ is @ for’,’ @ ’,’ geeks’) (’Ram is not eating but Mohan ’,’ is’, ’eating’)
Code # 2:
|
Output:
(’’, ’’, ’Sita is going to school’)
Code # 3: TypeError
|
Output:
Traceback (most recent call last): File "/home/e207c003f42055cf9697001645999d69.py", line 7, in print (str.rpartition ()) TypeError: rpartition () takes exactly one argument (0 given)
Code # 4: ValueError
|
Exit d:
Traceback (most recent call last): File "/home/c8d9719625793f2c8948542159719007.py", line 7, in print (str.rpartition ("")) ValueError: empty separator