<jupyter_start><jupyter_text>All the IPython Notebooks in this lecture series by Dr. <NAME> are available @ **[GitHub](https://github.com/milaan9/02_Python_Datatypes/tree/main/002_Python_String_Methods)**  Python String `partition()`The string **`partition()`** method splits the string at the first occurrence of the argument string and returns a tuple containing the part the before separator, argument string and the part after the separator.**Syntax**:```pythonstring.partition(separator)```  `partition()` ParametersThe **`partition()`** method takes a string parameter **`separator`** that separates the string at the first occurrence of it.  Return Value from `partition()`The **`partition()`** method returns a 3-tuple containing:* the part before the separator, separator parameter, and the part after the separator if the separator parameter is found in the string.* the string itself and two empty strings if the separator parameter is not found.<jupyter_code># Example 1: How partition() works?

string = "Python is fun"

# 'is' separator is found
print(string.partition('is '))

# 'not' separator is not found
print(string.partition('not '))

string = "Python is fun, isn't it"

# splits at first occurence of 'is'
print(string.partition('is'))<jupyter_output>('Python ', 'is ', 'fun')
('Python is fun', '', '')
('Python ', 'is', " fun, isn't it")
{'fraction_non_alphanumeric': 0.12573529411764706, 'fraction_numerical': 0.0058823529411764705, 'mean_word_length': 5.908629441624366, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '417925', 'license': 'MIT', 'n_tokens_mistral': 399, 'n_tokens_neox': 358, 'n_words': 157, 'path': '002_Python_String_Methods/031_Python_String_partition().ipynb', 'repo_name': 'Maxc390/python-discrete-structures', 'size': '1366'}