Inverse of dict(zip(x,y))

Tino Wildenhain tino at wildenhain.de
Wed Mar 4 06:17:25 EST 2009


lone_eagle wrote:
> Hi all,
> 
> This might be trivial ...
> 
> Can someone suggest a easy method to do the inverse of dict(zip(x,y))
> to get two lists x and y?
> 
> So, if x and y are two lists, it is easier to make a dictionary using
> d = dict(zip(x,y)), but if I have d of the form, d = {x1:y1,
> x2:y2, ...}, what is there any trick to get lists x = [x1, x2, ...]
> and y = [y1, y2, ...]

x,y=zip(d.items())

Cheers
Tino
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3241 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20090304/37c88f21/attachment.bin>


More information about the Python-list mailing list