views:

40

answers:

1

I have a dictionary (index2) of 3-item lists, organized by key from 0-150 or so. I need to sort it into another dictionary, with the following constraints:
1.) all items attached to one key must stay together in the second dictionary
2.) length of items in the second dictionary must all be the same. To help with this one, I divided the total number of items in the first dictionary by the number of keys in the second and attached it to a variable so it can be used as a limiting factor.

This is what I have so far, however when I run it, it doesn't actually append anything to the target dictionary.

for key,runs in index2.iteritems():  
    for a in mCESrange:  
        if index2[key][0] in mCESdict[a]:  
            pass  
        elif len(mCESdict[a]) < mCESlength:  
            pass  
        else:  
            mCESdict[a].extend(index2[key])  
A: 

Your problem description isn't really clear, and non-working code rarely helps to clarify, but I suspect that this line is your problem: elif len(dict[a]) < length.

Laurence Gonsalves
oops this was the problem. accept my humblest apologies.http://img29.imageshack.us/img29/9793/nrns.gif
Tob
@Tob: accept my answer, and I'll accept your humble apologies... :-)
Laurence Gonsalves