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
|
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week