Home >>Python String Methods >Python String partition() Method
Python string partition() method is used to look for a specified string and splits that string into a tuple containing three elements. the first element contains the part before the required string, the second element contains the required string and therefore the third element contains the part after the string.
Syntax:string.partition(value)
Parameter | Description |
---|---|
value | This is a required parameter. It defines the string to search for. |
txt = "Hi!! My name id Jerry and i'm a developer"
x = txt.partition("Jerry")
print(x)
txt = "Hi!! My name id Jerry and i'm a developer"
x = txt.partition("Abhi")
print(x)