Home >>Python String Methods >Python String rsplit() Method
Python String rsplit() Method splits a string and returns a list, starting from the right side by the Specified separator. It will same as the split() method except splitting from the right.
Syntax:string.rsplit(separator, maxsplit)
Parameter | Description |
---|---|
separator | It is Optional and is used to Specifies the separator to use when splitting the string. |
maxsplit | It is Optional. Specifies how many times number of splits to do. -1 is the default value. |
txt = "red, blue , orange, green"
x = txt.rsplit(", ")
print(x)
str = "javaScript is a scripting language"
str2 = str.rsplit('i')
print(str2)