How to Use String rpartition() Method in PythonPython Basics


The rpartition() splits a string at the last occurrence of the argument string.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

str = "www.ABCabcABC.com"

print(str.rpartition("."))

Output:

('www.ABCabcABC', '.', 'com')

Syntax

str.rpartition(separator)

Parameters

The method takes a string (separator) as the parameter.

Return Value

It returns a 3-tuple containing the part before separator, separator, and the part after separator.

© 2024 Cheerlearn.com, all rights reserved. Privacy Policy | Contact Us