adding values to keys
Brandon
your.master at gmail.com
Fri Feb 15 02:55:21 EST 2008
Hi all,
I'm not sure if I'm calling the right method in a dictionary. I have:
for k,v in dict.items():
NT = k,range(alpha,omega) #where alpha and omega are
previously defined as 1 and 4, respectively
print NT
which gives:
('w', [0,1,2,3])
('x', [0,1,2,3])
('y', [0,1,2,3])
('z', [0,1,2,3])
And now I want a master dictionary like: [{'w': [0],[1],[2],[3]},
{'x': [0]...]
So I try:
MT = {}
MT.fromkeys(NT[0], range(alpha,omega))
print MT
but this only returns:
{}
{}
{}...
Anybody see what I'm doing wrong? Any advice is much appreciated.
Thanks,
Brandon
More information about the Python-list
mailing list