Returning dictionary from a function

smarden1 at gmail.com smarden1 at gmail.com
Fri May 15 00:03:43 CEST 2009


def values(x):
    diky={}
    for a in range(x):
        a=a+100
        diky[chr(a)] = a
    return diky

it is not working b/c you are creating a new dictionary with each
iteration of the loop, rather you want to update the same dictionary
with the new value you have..



More information about the Python-list mailing list