![]() |
Python String rindex() method returns the highest index of the substring inside the string if the substring is found. Otherwise, it raises ValueError. Python String index() Method Syntax
Python String index() Method ExamplePython3
Output: Substring 'geeks': 10 Note: If start and end indexes are not provided then by default Python String rindex() Method takes 0 and length-1 as starting and ending indexes where ending indexes is not included in our search. Example 1: Python String rindex() Method with start or end indexIf we provide the start and end value to check inside a string, Python String rindex() will search only inside that range. Python3
Output: 0 0 5 Example 2: Python String rindex() Method without start and end indexPython3
Output: 5 2 Errors and Exceptions:ValueError: This error is raised when the argument string is not found in the target string. Python3
Exception: Traceback (most recent call last): File "/home/dadc555d90806cae90a29998ea5d6266.py", line 6, in result = text.rindex('pawan') ValueError: substring not found |
Reffered: https://www.geeksforgeeks.org
Python |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |