Introducing lists

Last week you looked at the role of functions in programming, and you learnt how to define and call your own functions with both parameters and return values. These are going to be really useful as you begin to implement your own algorithms.

Another programming technique that will be useful for algorithm writing is the use of lists to store data, as many algorithms involve manipulating data. Over the next few steps, you’re going to explore what lists are and how they work.

What is a list?

A list (also called an array) is a tool for storing data, just like a variable. However, whereas a variable can store one piece of data at a time in a named location, a list can store many.

Like a variable, a list is a named storage area within the computer’s memory. If you imagine the computer’s memory like a bookshelf, then each variable is like a named box on that shelf.