adding values to keys

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brandon

    adding values to keys

    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,o mega) #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,ome ga))
    print MT

    but this only returns:
    {}
    {}
    {}...

    Anybody see what I'm doing wrong? Any advice is much appreciated.

    Thanks,

    Brandon
Working...