Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day 4: Strings #265

Closed
AdityaDanturthi opened this issue Jul 26, 2022 · 1 comment
Closed

Day 4: Strings #265

AdityaDanturthi opened this issue Jul 26, 2022 · 1 comment

Comments

@AdityaDanturthi
Copy link

In the find() example
if find() returns the position first occurrence of 'y', then shouldn't it return 5 instead of 16?

AdityaDanturthi added a commit to AdityaDanturthi/30-Days-Of-Python-1 that referenced this issue Aug 9, 2022
### Fix for issue Asabeneh#265 

`find():` Returns the index of the first occurrence of a substring, if not found returns -1
challenge = 'thirty days of python'
print(challenge.find('y'))  # `5` instead of 16 (`since the index of the first 'y' is 5`)
print(challenge.find('th')) # `0`  instead of 17 (`since the index of the first 'th' is 0`)

`rfind():` Returns the index of the last occurrence of a substring, if not found returns -1
challenge = 'thirty days of python'
print(challenge.rfind('y'))  # `16 `instead of 5 (`since the index of the last 'y' is 16`)
print(challenge.rfind('th')) # `17` instead of 1 (`since the index of the last 'th' is 17`)
@Ifex370
Copy link

Ifex370 commented Sep 1, 2022

Still open

Repository owner locked and limited conversation to collaborators Jul 8, 2023
@Asabeneh Asabeneh closed this as completed Jul 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants