There are tons of things which you need an index for when iterating over an array. Do something different for every 4th element but then something else if it&#x27;s 16th. Keep doing something for triplets of elements unless you run into specific index which is divisible by 7, then start taking them one by one. Iterate but go 5 elements back if you encounter something in some state.
There are a lot of algorithms which take advantage of array being an indexed data structure with an order and not just plain container without structure.<p>The problem doesn&#x27;t just go away with for each style loops. Python added enumerate for this reason but it really is quite clumsy for anything more complicated (and you have to choose if it&#x27;s indexing from 0 or 1 anyway).