Str.partition and str.rpartition separate the string with separator available in string otherwise it will return tuple with string element and two empty string .
Syntax of Str.partition:
a.partition(-)
Output: tuple (head,sep,tail)
head=> the part before the seprator( hello in this case as shown in image)
sep=> the seprator(-) in this case.
tail=>The part after the separator(world in this case as shown in image)
The difference between str.opartition & str.rpartition is that str.partition function start from the beginning of the string whereas str.rpartition will search from the end of the string. As shown in below image
[…] 30.Str.partition: It sperate the string with separator and returns tuple with separator. […]