The rpartition Method in Python: Splitting a String from Right to Left into Three Parts
This method splits a string into three parts: start, separator, and end, and returns them as a tuple. It splits the string from right to left.
rpartition(sep)
sep-- separator string used to split the original string. It can have one or more characters. Returns a tuple with three elements.
The method behaves like partition, but splits the string from right to left.
my_str = ''
my_str.rpartition('.') # ('', '', '')
my_str = '12'
my_str.rpartition('.') # ('', '', '12')
my_str = '.1.2'
my_str.rpartition('.') # ('.1', '.', '2')