# 3.2. Lists & Looping¶

One of the main reasons to put data into lists is so that we can process the entire list in the same way. Instead of saying:

Do something with variableA
Do something with variableB
Do something with variableC
...


We can say:

Do something with item 1 from myList
Do something with item 2 from myList
Do something with item 3 from myList
...


Why is that important? Well, everything in those lines is the same except for the item number. We can use a counter to represent the item number and replace that list of instructions with a loop and one instruction. This video shows how:

Make sure you remember the basic recipe for working through a list:

Inside the repeat, if you want to talk about “the current item number” you use the counter index:

Inside the repeat, if you want to talk about “the current value” you use the item (index) of (list):

### Checkpoint Exercises

List Averager:

Make a block that averages the numbers in a list. You can start with the total numbers in list code from the 13:12 mark in the video. It already finds the total, you just need to divide that by the length of the list before reporting the answer.

Reverse Order:

Try making a block that says numbers in reverse order. Use the basic loop through list strategy, but. Start your index = to the length of the list. Change it by -1 inside the repeat to count down instead of up.