[Tutor] obtaining values from a dictionary
Julieta Rangel
julieta_rangel@hotmail.com
Sun, 06 May 2001 22:40:50 -0500
I have a list that looks like:
c = [('a', ('a', 'a')), ('a', ('a', 'b')), ('a', ('b', 'a')), ('a', ('b',
'b')), ('b', ('a', 'a')), ('b', ('a', 'b')), ('b', ('b', 'a')), ('b', ('b',
'b'))]
and I have a dictionary that looks like:
d ={('b', 'a'): 'a', ('a', 'a'): 'a', ('a', 'b'): 'b', ('b', 'b'): 'b'}
I want to replace the elements in my list according to my dictionary values.
In other words, I want to go element by element on my list and ask the
computer to give me the corresponding value, according to the dictionary.
For example, if I want to get the value of my second element in my list
('a',('a','b')), according to my dictionary, this is equal to ('a','b'),
which is equal to b. Can this be done?
Julieta
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com