Python lists

#Lists are useful as a way of assigning a series of values to a particular list name
#Those values can then be called by their position (index) in the series

myfridge = ['cheese', 'milk', 'beer']

#the square brackets indicate that this is a list
#each item in the list is separated by a comma
#items can then be called as follows:

myfridge[0]

#this would call the first item in the list (index position 0)

#you can also change the contents of a list with various functions as follows

myfridge.append('ham')

#this appends - .append - the string 'ham' to the list myfridge. 
#Note the full stop before .append and the parenthesis containing the argument to be passed
#the parenthesis could also use a variable instead of a string, or a function that returns a value, or another list

myfridge.pop(-1)

#this returns the last item in the list (at index position -1) and removes it from the list at the same time (pops)

#other functions include 
#counting how many times something occurs in a list - .count('ham')
#returning the index of a particular item in a list - .index('ham')
#removing the first instance in a list of a particular item - .remove('ham')
#inserting an item in a list at a particular position - .insert(3, 'ham')
#sorting items - .sort()
#reversing the order of items - .reverse()

#other list functions can be found at http://docs.python.org/tutorial/datastructures.html