By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,341 Members | 1,396 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,341 IT Pros & Developers. It's quick & easy.

adding values to keys

P: n/a
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
Feb 15 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.