This kind of thing is best done with `enumerate()`.