Python String – index() method

This is a method in python that returns the index of the first occurrence of the value. If not found throws an error. Syntax: List.index(value, starting_position, ending_position) Example 1: s = “code hustle repeat” x = s.index(“hustle”) print(x) Output: 1 Explanation: Here the word “hustle” occurred at index 1. Hence returned 1 Example 2: s […]

Python String – index() method Read More »