Introduction to Lists
CreatiCode last edited by info-creaticode
You already know how to use a variable as a box to store some number or text. When you work with a sequence of values, such as the ages of all your classmates, then you should use a “list” instead.
A list is an array of boxes, where each box has a different position number (indices).
Since all the boxes look the same, we need to use the position index number to refer to a box. For example, you can say “The box at position 2 contains the number 8”.
To create a new list, go to the “Variables” category, and click the “Make a list” button.
These steps are very similar to how you rename or delete a variable.
By default, a new list has no items (slots) in it. You can click the “+” button on its bottom left corner to add empty items. The “length” value will tell us how many items are in the list, which is how many values this list can carry.
When any item is selected, there is a small “x” on its right, which can be used to remove this item.
You can input numbers or text in any item of the list. If you press the ENTER key, a new empty item will be added below the current one, which makes it easier to enter many values.
Note that when you save the project, the content of the list is saved as well. So the next time you open this project, the list will contain the same content.