Python‎ > ‎str‎ > ‎

str.rpartition()


Definition
Search for the separator sep in S, starting at the end of S, and return the part before it, the separator itself, and the part after it.

Syntax
 S.rpartition(sep) -> (head, sep, tail)

Paramters
S=string

Examples
The equal to:
 >>> "Python Lake learning Centre".rpartition("Lake")
('Python ', 'Lake', ' learning Centre')
>>> 
>>> "Python Lake".rpartition("h")
('Pyt', 'h', 'on Lake')
>>> 

The returns are following:
 >>> "Python Lake".rpartition("h")
('Pyt', 'h', 'on Lake')
>>> type("Python Lake".rpartition("h"))
<class 'tuple'>
>>> z="Python Lake".rpartition("h")
>>> z=('Pyt', 'h', 'on Lake')
>>> z=('Pyt', 'h', 'on Lake')
>>> z.index('h')
1
>>> 'Pyt'+'h'+ 'on Lake'
'Python Lake'
>>> z.count("Lake")
0
>>> z.count('h')
1
>>>

Comments