Created
September 17, 2018 14:07
-
-
Save SZ-Edward/003e53003e65850725f56e65c62a5b60 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 all_indices(value, qlist): | |
indices = [] | |
idx = -1 | |
while True: | |
try: | |
idx = qlist.index(value, idx + 1) | |
indices.append(idx) | |
except ValueError: | |
break | |
return indices |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
print(all_indices("foo", ["foo","bar","baz","foo"]))