Skip to content

Instantly share code, notes, and snippets.

@raeq
Created July 18, 2020 20:27
Show Gist options
  • Save raeq/def9754284cab088c56980ca7187f08c to your computer and use it in GitHub Desktop.
Save raeq/def9754284cab088c56980ca7187f08c to your computer and use it in GitHub Desktop.
Find character indexes in string
def find_char_locations(original: str = "", character: str = "") -> list:
return [index for index, char in enumerate(original) if char == character]
assert find_char_locations("The jolly green giant.", "e") == [2, 12, 13]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment