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..