30-Days-Of-Python
30-Days-Of-Python copied to clipboard
Fix for issue #265 (Day 4: Strings)
Fix for issue #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)