Incorrect index() section uses find()

Author: myselfanandvpCreated Aug 19, 2026Updated Aug 19, 2026

Description

The index() section in 04_Day_Strings/day_4.py incorrectly demonstrates the find() method instead of the index() method.

Current content

# index(): Returns the index of substring
challenge = 'thirty days of python'
print(challenge.find('y'))  # 5
print(challenge.find('th'))  # 0


Why this is a problem

The section is labeled index(), but both examples use find():

challenge.find('y')
challenge.find('th')

This can be confusing for learners because find() and index() have similar behavior, but they are different string methods.

For example, when the substring is not found:

'hello'.find('x')    # -1
'hello'.index('x')   # ValueError

Suggested change

Replace the find() calls with index() calls:

# index(): Returns the index of substring
challenge = 'thirty days of python'
print(challenge.index('y'))  # 5
print(challenge.index('th'))  # 0

The existing find() section earlier in the file can remain unchanged.

Source: Asabeneh/30-Days-Of-Python