Created
August 4, 2016 13:11
-
-
Save erochest/88677a2e8ed439eb9bb0c4757f2de99b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def findall(haystack, needle): | |
i = 0 | |
while True: | |
j = haystack.find(needle, i) | |
if j is -1: | |
break | |
yield j | |
i = j + 1 | |
list(findall('abcadeaafghijak', 'a')) | |
# [0, 3, 6, 7, 13] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment