learn-python icon indicating copy to clipboard operation
learn-python copied to clipboard

Fix Incorrect Comment in String Indexing Example

Open fancling opened this issue 2 years ago • 0 comments

Hello,

I've noticed a small error in the comments of the string indexing example provided in the [src/data_types/test_strings.py]. The comment incorrectly refers to the sixth character of the string as the "Fifth character".

Current Code: word = 'Python' assert word[0] == 'P' # First character. assert word[5] == 'n' # Fifth character. Issue: The comment for assert word[5] == 'n' incorrectly states "Fifth character" while it actually checks the sixth character of the string word.

Suggested Correction: word = 'Python' assert word[0] == 'P' # First character. assert word[5] == 'n' # Sixth character. Correction Explanation: Python strings are zero-indexed, so the first character is at index 0, and the sixth character is at index 5. The proposed change corrects the comment to accurately reflect the character's position in the string.

I hope this helps improve the documentation/code for future readers. If it's okay, I can submit a pull request #83 with this minor fix.

Thank you for your attention to this matter.

Best regards, fancling

fancling avatar Dec 27 '23 06:12 fancling