Unit 8 · Lesson 5
Build the idea
Start with the concept and its key vocabulary.
To visit every array element, use the loop counter as its index. ERL loops from 0 to array.length - 1 because to is inclusive. Python range(len(array)) naturally produces the same valid indices. Starting at 1 misses the first element; ending at length goes out of bounds.
Visiting each item in a data structure in a systematic order.
The changing for-loop variable that can be used as an array index.
Checking array values one by one in order until a target is found or the list ends.
Starting or ending a traversal one index too early or too late.