The partition() method in Python cuts a string into three parts with a delimiter.

Syntax

This method will only search the first occurrence of the delimiter.

Return value

This method will return a tuple with three values: the string before the delimiter, the delimiter itself, and the string after it.

If it doesn’t find the delimiter, it will return a tuple with only the string as the first element.