In the previous lessons, you have used the Finch sensors to make measurements, and you have stored these measurements in variables. In this lesson, you will learn to use a new type of variable called a list. A list can hold many values, instead of just one.
Table of Contents
To add items to a list, you can use the add to block in the Data menu. For example, the block below adds the number 3 to practiceList. Try adding a few other values to practiceList. Notice that each value is added to the bottom of the list. By default, the list is shown in the stage area, although you can deselect the list to hide it.


Exercise 1:
Write a program that records 60 measurements with the light sensor. The program should wait 0.5 seconds between measurements. Be sure to save this code, because you will need it later.
Often, you will want to use a loop to move through all of the items in a list. You can do this using a counter variable and a repeat block. An example is shown below. At the beginning of the program, practiceList is set to contain three items. Before the repeat block, the variable count is set to 1, corresponding to the first item in the list. In order to repeat the contents of the loop for each item in the list, the number of repetitions in the repeat block is set to the length of the list using the length of block (Data menu). Each time through the loop, the item in the list that corresponds to count is displayed, and then the value of count is increased by 1. Try out this script to make sure you understand how it works.

Exercise 2:
Return to your program from the last exercise. After you collect the accelerometer measurements, use a loop to move through the list. Use each item in the list to determine the position of the sprite on the screen. Remember, you may need to scale the accelerometer value so that you can see the sprite move.
Exercise 3:
Search through your list to find the largest value.
Exercise 4:
Finally, modify your program so that it calculates the sum of the items in your list in a variable called sum. Then calculate the mean acceleration.