Created
February 10, 2013 04:06
-
-
Save gnerkus/4748310 to your computer and use it in GitHub Desktop.
Search for a character in an iterable and return an index of all occurrences of that character.
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 recursvfind (search, target, start=0, pos=[]): | |
current_pos = str(target).find(search, start) | |
if current_pos < 0: | |
return pos | |
else: | |
return recursvfind(search, target, current_pos + 1, pos + [current_pos]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment