I have a dictionary in which 3 keys are assigned to each value: dictTest[c,pH,T] = value. I would like to retrieve all values corresponding to a given, single key: dictTest[c,*,*] = value(s)
I looked online but could not find any solutions in Python, only C#. I've tried using dictTest[c,*,*] but get a syntax error. Another option I can see is using multi-level keys, i.e. have the first level as c, second as pH and so on, i.e. dictTest[c][pH][T] = value (from http://python.omics.wiki/data-structures/dictionary/multiple-keys)
Here is some test code:
dictTest={}
dictTest[1,100,10]=10
dictTest[1,101,11]=11
The following gives a syntax error:
print(dictTest[1,*,*])
Whilst trying to specify only one key gives a key error:
print(dictTest[1])
I've also tried the above mentioned multi-level keys, but it raises a syntax error when I try and define the dictionary:
dictTest[1][100][10]=10
In the above example, I would like to specify only the first key, (i.e. key1=1, and return both values of the dictionary, as the first key value of both is 1.
Thanks, Mustafa.