# Python - String rsplit() Method

The string rsplit() method is used to split the string into a list. It has two optional parameter which can be used to specify separator for split operation and number of splits.

If the number of split is not provided, this method gives the same result as split(). The only difference between split() and rsplit() methods is that split() method starts spliting operation from left side and rsplit() method starts spliting operation from right side.

### Syntax

string.rsplit(separator, max)


### Parameters

 separator Optional. specify separator character for split operation. default value is whitespace. max Optional. specify number of split. default value is maximum number of split possible.

### Example:

In the below example, rsplit() method is used to split the string into a list. If the specified separator is not found in the string, the rsplit() method returns the whole string as single element of the list.

MyString = "Python Java C++"
print(MyString.rsplit())

MyString = "Python#Java#C++"
print(MyString.rsplit("#"))

MyString = "Python#Java#C++"
print(MyString.rsplit("#", 1))

MyString = "Python Java C++"
print(MyString.rsplit("#"))


Output

['Python', 'Java', 'C++']

['Python', 'Java', 'C++']

['Python#Java', 'C++']

['Python Java C++']