If we wanted to access different items in a list, we need a variable to specify the numerical value of the index of the list.



1. First, it is important to name your variables that you can keep track of them. Notice how this variable is labeled indexExcuse. This tells me that this variables will be used to control the index in the Excuse list.

Index1.png

2. To control the index we need to:

A) Add to the index (to change it)

To add to the index we will use set statement to set our Variable indexExcuse to the original indexExcuse (get indexExcuse) + 1. This is called incrementing.
IndexAdd.png

B) Use the index

Now will we need to use the index variable that we have created by assigning the variable indexExcuse to the index option in our list.
IndexUse.png

C) Ask if the index is too big

A) If we just keep adding to the indexExcuse, it will eventually get bigger than the list. Luckily, we can easily ask the length of the list.
B) We use an expression (yielding a true false) to ask if our current index is too large.
C) We use an if.then.else to reset the indexExcuse when it gets too large.
IndexBig.png


3. What if there is nothing in the list?

A) That is really a special case we should check for. If we try to access the first element in an empty list, the device will be unhappy.

B) We need to handle that special case with an if.then.else. Often in computing a significant amount of effort is spent in checking for these special cases. If your code works 99% of the time, we call it WRONG!


IndexEmpty.png