In [1]:
months = ('January','February','March','April','May','June',\
'July','August','September','October','November',' December')
In [2]:
cats = ['Tom', 'Snappy', 'Kitty', 'Jessie', 'Chester']
In [4]:
print (cats[2])
In [5]:
cats.append('Catherine')
Dictionaries are similar to what their name suggests - a dictionary. In a dictionary, you have an 'index' of words, and for each of them a definition. In python, the word is called a 'key', and the definition a 'value'. The values in a dictionary aren't numbered - tare similar to what their name suggests - a dictionary. In a dictionary, you have an 'index' of words, and for each of them a definition. In python, the word is called a 'key', and the definition a 'value'. The values in a dictionary aren't numbered - they aren't in any specific order, either - the key does the same thing. You can add, remove, and modify the values in dictionaries. Example: telephone book.
In [6]:
#Make the phone book:
phonebook = {'Andrew Parson':8806336, \
'Emily Everett':6784346, 'Peter Power':7658344, \
'Lewis Lame':1122345}
In [8]:
#Add the person 'Ram' to the phonebook:
phonebook['Ram'] = 1234567
In [9]:
del phonebook['Andrew Parson']