That Blue Square Thing

AQA Computer Science GCSE

February 2019: this area of the site is being built just now. There are areas where there is no content yet. That will get added over the next 6 months or so.

Programming project - Working with Lists

Lists can be extremely powerful tools to use in a programming project. It might be that you use simple lists to hold data, have to read in or write a list of data or use 2D arrays (lists of lists) to manipulate data.

The File Read/Write page deals with how to read a list of lists from a text file and store it. The Unit 2 Using readline for lists deals with how to create a simple list from a text file.

Basic Strategy for Working Through a List

Using lists require a methodical approach. The pseudocode below shows one way to do that (don't forget that lists are called arrays in pseudocode).

FOR aLine in an array
nextItem <- aLine # take the next item and store it
do whatever needs doing

One way that this technique could be implemented in Python is:

for aLine in aList:
nextItem = aLine
# do whatever needs doing

There are, of course, a whole range of things you might do to the items in the array.