The rsplit Method in Python: Splitting a String from Right to Left

This method splits a string into parts using a delimiter and returns these parts as a list. Splitting occurs from right to left.

rsplit(sep=None, maxsplit=-1)

  • sep=None -- delimiter string used to split the original string. It can contain one or more characters. If not specified, a special algorithm is used where the delimiter is a sequence of whitespace characters.
  • maxsplit=-1 -- maximum number of splits to perform. If -1, the number of splits is unlimited.

The method behaves similarly to split, except it splits the string from right to left.