Skip to content

Instantly share code, notes, and snippets.

Created August 31, 2015 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/9818f59cfa05e4d0c645 to your computer and use it in GitHub Desktop.
Save anonymous/9818f59cfa05e4d0c645 to your computer and use it in GitHub Desktop.
def find_last(search, target):
pos = 0
position = search.find(target)
if position < 0:
return position
else:
while position >= 0:
first_pos = search.find(target)
position = search.find(target, first_pos + pos)
pos = pos + 1
if position < 0:
break
return position
else:
final_pos = search.find(target, position)
return final_pos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment