Python String index() MethodPython index() method is same as the find() method except it returns error on failure. This method returns index of first occurred substring and an error if there is no match found. SignatureParameters
Return TypeIf found it returns an index of the substring, otherwise an error ValueError. Let's see some examples to understand the index() method. Python String index() Method Example 1Output: 18 Python String index() Method Example 2An error is thrown if the substring is not found. Output: ValueError: substring not found Python String index() Method Example 3We can also pass start and end index as parameters to make process more customized. Output: p is present at : 20 index
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