Python String rindex() MethodPython rindex() method works same as the rfind() method except it throws error ValueError. This method throws an exception ValueError if the substring is not found. The syntax is given below. SignatureParameterssub : substring to be searched. start (optional) : starting index to start searching. end (optional) : end index where to search stopped. ReturnIt returns either index of substring or throws an exception ValueError. Let's see some examples of rindex() method to understand it's functionality. Python String rindex() Method Example : Simple ExampleA simple example is created first to see how to implement this method. This method returns index of the substring. Output: 18 Python String rindex() Method Example 2This method accept parameters start and end index to search subtring from the substring. See the example below. Output: 18 6 Python String rindex() Method Example 3If the substring is not found in the string, it raises ValueError. See the example below. Output: ValueError: substring not found Next TopicPython Strings |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India