© 2004-21

Using a 1D List

Think of a list like a set of boxes joined together.
On the front of the box is a number so that you can identify what is in the box by referring to its number.
You can put anything in the box and find the contents by referring to its number.

The code snippet demonstrates how to setup the data and then add an item to it

# Author: your name here
# Date:
# Purpose: Learn how to manage lists

print ("Managing a List \n")

# set up the initial contents of the list
listFruit = ["Orange", "Apple", "Mango"]

#display what is in the list

#initialise as new string variable with a fruit name
newFruit =    #add the name of a new fruit here

# type the the next line of code use the append method  to add newFruit

#display the updated contents of the list - use the code from line 12