more_itertools.locate
is a third-party tool that finds all indicies of items that satisfy a condition.
Here we find all index locations of the letter "i"
.
import more_itertools as mit
s = "supercalifragilisticexpialidocious"
list(mit.locate(s, lambda x: x == "i"))
# [8, 13, 15, 18, 23, 26, 30]