I am a python beginner and created a short dictionary that links capital letters as keys to 1x3 arrays as the respective values. So something similar to this:
dict = {'A': array([1, 2, 3]), 'B': array([2.1, 3.2, 4]), etc. }
As part of my program I need to assign the key to the value as a function. But instead of writing:
A = array([1, 2, 3])
B = array([2.1, 3.2, 4])
etc.
I want to find a more general, abstract, simpler code. So far I could come up with:
for i in dict:
i = dict[i]
But this does not quite work and I am unsure why. Sorry that I can not give a better error description here, but I don't have access to my code at the moment. Any help is appreciated! Thanks in advance!
i, not to the name that's in the string pointed to byi.)iin each iteration. Try changingi = dict[i]tovalue = dict[i]to see that the loop should then work.dictis the name of a frequently-used, built-in Python data structure, so you might want to avoid that name in your own code to mean something else.