[Tutor] Update values stored as a list in a dictionary with values from another dictionary

GTXY20 gtxy20 at gmail.com
Tue Oct 2 07:56:48 CEST 2007

Hello all,

Let's say I have the following dictionary:

{1:(a,b,c), 2:(a,c), 3:(b,c), 4:(a,d)}

I also have another dictionary for new value association:

{a:1, b:2, c:3}

How should I approach if I want to modify the first dictionary to read:

{1:(1,2,3), 2:(1,3), 3:(2,3), 4:(1,d)}

There is the potential to have a value in the first dictionary that will not
have an update key in the second dictionary hence in the above dictionary
for key=4 I still have d listed as a value.

As always all help is appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071002/47d72599/attachment-0001.htm 

More information about the Tutor mailing list