Hi Experts,
I was wondering how to do the following:
I have three strings that have five numbers assigned to them for instance, 'a' can equal 1, 2, 3; 'b' can only equal 4 and 'c' can only equal 5.
some process happens and I get a result of an integer 1 - 5, say 3 - I would then like the script to tell me what string is assigned to it, in this case 'a'...
I had something like this:
z = {'a': 1, 'a': 2, 'a': 3, 'b': 4, 'c': 5)
# ~ insert process here ~
# number 3 returned
x = z.get(3)
print x
# I expect it to tell me that 'a' is associated with 3 but I get "None"
## I also tried:
print z[2];
For which I get
Traceback (most recent call last):
File "<pyshell#54>", line 1, in <module>
print z;
KeyError: '2'
The key error changes from 1-5 dependent on which one I call in the print z["NUMBER"]
Any thoughts? I also tried:
z = {'a': 3, 'b': 4, 'c': 5)
but it spits this out:
x = z.get(3)
>>> print x
None
Cheers