Ben Finney wrote: > [EMAIL PROTECTED] writes: > > >>I have next dictionaries: >>a={'a':0, 'b':1, 'c':2, 'd':3} >>b={'a':0, 'c':1, 'd':2, 'e':3} >>I want to put in a new dictionary named c all the keys that are in b >>and re-sequence the values. > > > They never had a sequence, so you can't "re-sequence" them. > > You have not, perhaps, worked your way through the Python > tutorial. It's quite comprehensive and will give you a good grounding > in the basic concepts. > > <URL:http://docs.python.org/tut/> >
The values in the example are sequentially ordered wrt the keys, which is perhaps what the OP intends. c = dict(((k,v) for (v,k) in enumerate(x for x in sorted(a.keys()) if b.has_key(x)))) But, yes, there is decided ambiguity in his description of the problem. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list