for idx, a in enumerate(foo):
foo[idx] = a + 42
Note though, that if you’re doing this, you probably should look into list comprehensions (or map), unless you really want to mutate in place (just don’t insert or remove items from iterated-on list).
The same loop written as a list comprehension looks like:
foo = [a + 42 for a in foo]