# Python - String partition() Method

The string partition() method is used to create three partition of the string and returns them in tuple form. The three elements of tuple will be: portion of the string before first occurrence of the specified character(s), the specified character and remaining portion of the string after first occurrence of the specified character(s).

### Syntax

string.partition(characters)


### Parameters

 characters Required. specify character(s) which need to be searched in the string.

### Example:

In the below example, partition() method is used to create three partition of the string and returns them in tuple form.

MyString = "Python#Java#C++"
print(MyString.partition("#"))


Output

('Python', '#', 'Java#C++')


### Example:

If the specified character(s) is not present in the string then the three elements of tuple will be: the whole string, ' ' and ' '.

MyString = "Python#Java#C++"
print(MyString.partition("Javascript"))


Output

('Python#Java#C++', '', '')