Incorrect index() section uses find()
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 92/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- python
- Domain
- documentation
Research direction
Open 04_Day_Strings/day_4.py and locate the index() section. Compare it with the surrounding find() section, then change the two calls in the index() examples so they demonstrate index() and retain the shown outputs. Done means the section is labeled index() and no longer uses find(), while the earlier find() section remains unchanged.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 74.2k
- Forks
- 13.5k
- Avg merge
- 5d 5h
- Merged PRs (30d)
- 4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Asabeneh/30-Days-Of-Python
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Asabeneh/30-Days-Of-Python#957 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Asabeneh/30-Days-Of-Python#924 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Asabeneh/30-Days-Of-Python#920 ·
-
Minor error in day 3 Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Asabeneh/30-Days-Of-Python#915 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Asabeneh/30-Days-Of-Python#914 · 2 comments ·
All issues in Asabeneh/30-Days-Of-Python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100