On 27/10/2015 21:37, jarod_v6--- via Tutor wrote:
Sorry,
I just realize my question are wrong: I want to knowhow to do dictionary of
dictionary in most python way:

diz = { "A"={"e"=2,"s"=10},"B"={"e"=20,"s"=7}}

So I have some keys (A,B) is correlate with a new dictionary where I have
other key I want to use. I want to extract for each key the "e" value.
thanks


So having sorted out the dict syntax how about.

>>> diz = {"A":{"e":2,"s":10},"B":{"e":20,"s":7}}
>>> es = {}
>>> for k,v in diz.items():
...     es[k] = v["e"]
...
>>> es
{'B': 20, 'A': 2}

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to