Python String rpartition() Method
Searches the source string from the right for the first match of the specified substring and returns a tuple with everything to the left of the match (from the right), the match, and everything to the right of the first match (again, from the right.)
Syntax
Python
Copy Code
string.partition(value)
Parameters
Parameter | Description |
---|---|
value |
Required. The string to search for |
Example
Python
Copy Code
str = 'You say tomato, I say tomato, the French say tomate.' print(str.rpartition('tomato'))
Output
('You say tomato, I say ', 'tomato', ', the French say tomate.')