Let's say I have two dictionaries:
dict1 is 1:23, 2:76, 4:56
dict2 is 23:A, 76:B, 56:C
How do I get a dictionary that is
1:A, 2:B, 4:C
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
Let's say I have two dictionaries:
dict1 is 1:23, 2:76, 4:56
dict2 is 23:A, 76:B, 56:C
How do I get a dictionary that is
1:A, 2:B, 4:C
dict1 = {1:23,2:76,4:56}
dict2 = {23:'A',76:'B',56:'C'}
dict((k, dict2[v]) for k, v in dict1.items())
{1: 'A', 2: 'B',
[EMAIL PROTECTED] wrote:
Let's say I have two dictionaries:
dict1 is 1:23, 2:76, 4:56
dict2 is 23:A, 76:B, 56:C
How do I get a dictionary that is
1:A, 2:B, 4:C
dict1 = {1:23, 2:76, 4:56}
dict2 = {23:'A', 76:'B', 56:'C'}
dict((key, dict2[value]) for key, value in
Let's say I have two dictionaries:
dict1 is 1:23, 2:76, 4:56
dict2 is 23:A, 76:B, 56:C
How do I get a dictionary that is
1:A, 2:B, 4:C
d1={1:23,2:76,4:56}
d2={23:a, 76:b, 56:c}
result = dict([(d1k,d2[d1v]) for (d1k, d1v) in d1.items()])
result
{1: 'a', 2: 'b', 4: 'c'}
If
Op 2006-02-27, [EMAIL PROTECTED] schreef [EMAIL PROTECTED]:
Let's say I have two dictionaries:
dict1 is 1:23, 2:76, 4:56
dict2 is 23:A, 76:B, 56:C
How do I get a dictionary that is
1:A, 2:B, 4:C
Well how about the straight forward:
dict3 = {}
for key, value in dict1.iteritems():
[EMAIL PROTECTED] wrote:
Let's say I have two dictionaries:
dict1 is 1:23, 2:76, 4:56
dict2 is 23:A, 76:B, 56:C
How do I get a dictionary that is
1:A, 2:B, 4:C
Just copy/paste the following source code to a file and run it:
code
sourceCodeToExecute =
dict1 = { 1:23,2:76, 4:56
In article [EMAIL PROTECTED],
[EMAIL PROTECTED] wrote:
Let's say I have two dictionaries:
dict1 is 1:23, 2:76, 4:56
dict2 is 23:A, 76:B, 56:C
How do I get a dictionary that is
1:A, 2:B, 4:C
The following should work:
j = dict((k, dict2[dict1[k]]) for k in dict1 if dict1[k] in