kk schrieb:
Hi
I am working on something here and I cannot get the full dictionary
out of a function. I am sure I am missing something here.
Anyways here is a simple code that repeats my problem. Basically I am
just trying to get that values function to return the diky as a
dictionary so that I can query values later.
thanks
def values(x):
diky={}
for a in range(x):
a=a+100
diky={chr(a):a}
print diky
return diky
b=values(5)
print type(b),len(b), b['f'] # gives error
print type(b),len(b), b['h'] # does not give error
You are creating a new dictionary over and over.
dikiy[chr(a)] = a
is what you want inside the loop.
Diez
--
http://mail.python.org/mailman/listinfo/python-list