Python String rsplit() method

The string.rsplit() method in Python splits a string into a list, starting from the right. If the “max” parameter is not specified, this method will return the same output as the string.split() method.

Syntax

string.rsplit([sep [,maxsplit]])

Parameter

sep (optional): This parameter specifies the separator to use when splitting the string. The default value is whitespace.

maxsplit (optional): This parameter Specifies how many splits to do. The default value is -1, which is “all occurrences”.

Return

This method returns a list of the words in the string, using sep as the delimiter string. 

Example 1

Output

Example 2

Output

Pin It on Pinterest

Share This