Home >>Python String Methods >Python String rpartition() Method
Python String rpartition() Method in python splits the string from the index of parameter of a specified string and returns the tuple. The tuple splits the string into three parts before the separator, argument of the string and the part after the separator. If the separator not found, it returns the empty tuple.
Syntax:string.rpartition(value)
Parameter | Description |
---|---|
value | It is Required to search the string |
txt = "blue color is my lucky color, blue color are my favorite color"
p = txt.rpartition("blue")
print(p)
rpart = "javaScript is a scripting language"
rpart2 = rpart.rpartition("is")
print(rpart2)
rpart2 = rpart.rpartition("javaScript")
print(rpart2)
rpart2 = rpart.rpartition("language")
print(rpart2)
rpart2 = rpart.rpartition("va")
print(rpart2)