Skip to content

Instantly share code, notes, and snippets.

@gnerkus
Created February 10, 2013 04:06
Show Gist options
  • Save gnerkus/4748310 to your computer and use it in GitHub Desktop.
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.
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