That Blue Square Thing

AQA Computer Science GCSE

July 2019: the AQA CompSci area is almost complete. Most of the content for units 3-6 is now up and there's quite a lot of Unit 7 material. There's still some work to do, particularly on Paper 1 units, but it's getting there.

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 anArray
nextItem <- aLine # take the next item and store it
# do whatever needs doing

ENDFOR

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.