I have some issues with the eval
function. I have a list like, for example,
list1 = [('a',1), ('b',2), ('c',3)]
and I would like to assign each value of a tuple to the first element:
for el in list1 :
eval(el[0]) = el[1]
How can I do this?
You could do this:
But don't. Really, don't. You don't need dynamic local variables, you need a dictionary: