I am trying to make a residual plot for a bunch of different filters. I have around 23 filters to worry about so 23 plots in total. Each plot is supposed to be residual value vs redshift of a galaxy. To do this I wanted to use a dictionary that had lists within for each filter and their respected residual value for all the galaxies I'm working with. Something along the lines of 

```py
resid = {}
resid[VIMOSV]['resid'] = 0.4, 0.2, 0.7, 1.1, 0.9
resid[VIMOSV]['z'] = 1.1, 1.0, 0.9, 0.8, 1.2

```

so that the key for my resid dictionary is the filter name, followed by another key to pull up residual values or the z values. This is what my code actually looks like:

```py
resid = {}
residval = ((residfiledat[iline]['tempa_zprior'] - residfiledat[iline]['flux_cat']) 
                    / residfiledat[iline]['flux_cat'])
if key in resid:
                        resid[key]['resid'] = np.append(resid[key]['resid'], residval)
                        resid[key]['z'] = np.append(resid[key]['z'], 
                                                    zdat[clustname[iclust]]['spec_z'][goodindx[clustname[iclust]][igood]])
                        print('key:' , key , 'exists', resid[key])

                    else: 
                        #now make the dictionary entry because it doesn't exist
                        resid[key]['resid'] = np.array([])
                        resid[key]['z'] = np.array([])  
                        resid[key]['resid'] = np.append(resid[key]['resid'], residval)
                        resid[key]['z'] = np.append(resid[key]['z'], 
                                                    zdat[clustname[iclust]]['spec_z'][goodindx[clustname[iclust]][igood]])
                        print('key created', key, resid[key])

```

The values from the residval are from a prior loop that I know works. My error comes from the else statement:
'keyerror Traceback(most recent call last)
else:
resid[key]['resid'] = np.array([])
keyerror: 'FOURSTARKs'

I looked it up and this is basically telling me that the key does not exist, but that was the entire point of the else statement. If the key exists, add the values to it, else: create the key. I clearly don't know how to add a key to a dictionary that has to hold a list so help would be awesome.