Python - String Method - rsplit() Tutorial
It will break or split the string from the right at the specified separator and return a list of strings. If max split is not specified as a parameter, it will return the list the same as split()
Syntax-
String.rsplit(separator,maxsplit)
#separator- (Optional) Separator value at which split
should occur in the given string
#maxsplit- (Optional) Maximum number of splits that
should occur in String Starting from right.
By default there is no limit on the number of splits.
Example-
str1 = "Python is a cross-platform object-oriented general-purpose,
high-level programming language"
print(str1.rsplit("-"))
print(str1.split("-"))
print(str1.rsplit("-",2))
print(str1.split("-",2))
Output-
['Python is a cross', 'platform object', 'oriented general', 'purpose, high',
'level programming language']
['Python is a cross', 'platform object', 'oriented general', 'purpose, high',
'level programming language']
['Python is a cross-platform object-oriented general', 'purpose, high',
'level programming language']
['Python is a cross', 'platform object', 'oriented general-purpose,
high-level programming language']