Python String partition() Method
Searches for the specified substring to match on and returns a tuple of three strings: everything before the match, the match string, everything after the match string.
Syntax
Python
Copy Code
string.partition(value)
Parameters
Parameter | Description |
---|---|
value |
Required. The string to search for |
Example
Python
Copy Code
str = 'The quick brown fox jumped over the lazy dog' print(str.partition('fox'))
Output
('The quick brown ', 'fox', ' jumped over the lazy dog')