Function Details: partition

Description


Partition the string into three parts using the given separator.


Extended Description


The partition() method splits the string at the first occurrence of the specified separator and returns a tuple containing three elements: the part before the separator, the separator itself, and the part after the separator. If the separator is not found, it returns a tuple containing the original string and two empty strings.


Read More about partition from Python Documentation

Function Signature



Module: builtins

Class: str

Parameters



Parameter List


  • sep: str

Return


Returns a tuple of three strings: (part_before_separator, separator, part_after_separator)


Return Type


Tuple[str, str, str]

Output

Explanation

This example demonstrates the basic usage of partition(). It splits the string at the first occurrence of '-'.