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
string.partition(value)

Parameters

ParameterDescription
value Required. The string to search for

Example

Python
str = 'The quick brown fox jumped over the lazy dog'
print(str.partition('fox'))

Output

('The quick brown ', 'fox', ' jumped over the lazy dog')