Function Details: rsplit

Description

Returns a list of the words in the string, using sep as the delimiter string.

Extended Description

rsplit is a Python string method that splits string into list of substrings from right to left. Belongs to string partitioning family with split and rpartition, offering right-side directionality. Works with strip for clean text processing and join for string reconstruction. Without arguments, splits on whitespace like split. Optional maxsplit parameter is particularly useful for right-side limited splits, making it ideal for parsing file paths, URLs, or nested identifiers. Returns list of split strings in original order. Essential for right-to-left text processing workflows.


Read More about rsplit from Python Documentation

Function Signature



Module: builtins

Class: str

Parameters



Parameter List


  • sep: str
  • maxsplit: int

Input String

No Separator Given

Separator Given

Splits on ANY Whitespace
RIGHT to LEFT
'Hello World' → ['Hello', 'World']

Separator Found
'a,b,c'.rsplit(',') → ['a', 'b', 'c']
Same as split() when no maxsplit

Separator Not Found
'apple'.rsplit(',') → ['apple']
Same as split()

With maxsplit=1
Starts from RIGHT
'a,b,c'.rsplit(',', 1) → ['a,b', 'c']
Different from split(): ['a', 'b,c']

Empty Separator
'python'.rsplit('')

ValueError:
empty separator
Same as split()

Return


Returns a list of substrings


Return Type


List[str]

Output

Explanation

Basic usage of rsplit() to split a string by commas.