Lists - Lakelands Computing

Title
Go to content
Lists
A variable lets you store a single piece of data. If you want to store more than 1 piece of data for example a name and an age you either need 2 variables, or you need a list. Lists are sometimes called Arrays.

The real advantage of a list is you can several pieces of data.

A simple list might be ["Dave","Steve","Bob"] - there are 3 entries.

Entry 0 is "Dave", Entry 1 is "Steve", Entry 2 is "Bob" - computers start counting at 0 not 1.

We can also have a "2D" list  [["Dave",28],["Steve",32],["Bob",42]].

Entry 0 is ["Dave",28] - with a 2D list we have a list in each position in the list.

Entry 0,0 is Dave - the first value in the small list that is in the first slot of the main list

There are alternatives to lists, such as Dictionaries which links the 2 values together but is in a random order where as a list stays in the same order (unless you tell it to change)
All Text copyright Lakelands Academy & Mr T Purslow 2020.
All images copyright free / creative commons unless otherwise stated.
You are welcome to use under a Creative Commons Attribution-nonCommercial-ShareAlike License.
All Text copyright Lakelands Academy & Mr T Purslow 2020.  All images copyright free / creative commons unless otherwise stated. You are welcome to use under a Creative Commons Attribution-nonCommercial-ShareAlike License.
All Text copyright Lakelands Academy & Mr T Purslow 2020.  All images copyright free / creative commons unless otherwise stated. You are welcome to use under a Creative Commons Attribution-nonCommercial-ShareAlike License.
Back to content