Python String rpartition() Method

Last Updated : 5 Jan 2026

Python rpartition() method splits the string at the last occurrence of seperator substring.It splits the string from the last occurrence of parameter and returns a tuple. The tuple contains the three parts before the separator, the separator itself, and the part after the separator.

It returns an empty tuple having seperator only, if the seperator not found.

Syntax of Python String repartition() Method

The method signature is given below.

Parameters

  • sep: A string parameter which separates the string.

Return

It returns a tuple, A 3-Tuple.

Different Examples for Python String rpartition() Method

Let's see some examples of rpartition(sep) method to understand it's functionality.

Example 1

Let's see a simple use of partition method in various scenario.

Output:

('Java ', 'is', ' a programming language'')
('', 'Java', ' is a programming language')
('Java is a programming ', 'language', '')
('J', 'av', 'a is a programming language')

Example 2

if the separator is not found, It returns a tuple containing string itself and two empty strings to the right. See the example below.

Output:

('', '', 'Java is a programming language')
 
Next TopicPython Strings