var = {'hello': 'world', 'good': 'day', 'see': 'you'}
Function:
def func(key):
return newfunc(var[key])
I would like to get something like this: hello = func('hello') = newfunc('world')
.
varlist = list(var.keys())
for i, variab in enumerate(varlist):
varname = variab
variab = func(varname)
But the problem at last the variables are not defined because the variable variab
is overwritten when the next iteration starts. So do I have other ways to code a for
loop to define all the variables in the dict?
I know I can keep writing hello = func('hello')
and other variables every line but I would like to know if another method is possible.