Use a dictionary!
my_dictionary = { #Use {} to enclose your dictionary! dictionaries are key,value pairs. so for this dict 'fruit' is a key and ['d', 'e', 'f'] are values associated with the key 'fruit'
'fruit' : ['d','e','f'], #indentation within a dict doesn't matter as long as each item is separated by a ,
'candy' : ['a','b','c'] ,
'snack' : ['g','h','i']
}
print my_dictionary['fruit'] # how to access a dictionary.
for key in my_dictionary:
print key #how to iterate through a dictionary, each iteration will give you the next key
print my_dictionary[key] #you can access the value of each key like this, it is however suggested to do the following!
for key, value in my_dictionary.iteritems():
print key, value #where key is the key and value is the value associated with key
print my_dictionary.keys() #list of keys for a dict
print my_dictionary.values() #list of values for a dict
dictionaries by default are not ordered, and this can cause problems down the line, however there are ways around this using multidimensional arrays or orderedDicts but we will save this for a later time!
I hope this helps!