Solution Review: Find Index of a Specific Value in a String

This lesson gives a detailed review on how to find the index of a specific value in a string.

We'll cover the following

Solution: Use find()

Use the built-in string function string.find(character) to find the index of a specific character in a string; this returns the index of the input character or string

For example:

Given

str = "Python Programming"
character = "y"
str.find(character)

Output:1

The following Python code demonstrates how to find the index of a specific value in a string.

Get hands-on with 1200+ tech skills courses.