This might be a silly question, but for some reason the solution escapes me at the moment.
I would like to have fast and efficient access to data that is in a list format. So for example a list of questions:
q = {}
q[1] = "my first string"
q[2] = "my second string"
q[3] = "my third string"
I can easily find what question 2's string is by doing q[2]. But I would also like to retrieve the question number by indexing q with the string:
q["my second string"] -> gives 2 as answer
I would like to do this without iterating over the keys (defeats the purpose of a dictionary) and like to avoid defining a second dictionary using the string as the key to avoid wasted memory. Is this possible?
Ultimately the reason for this is I would like to access say q[2] or q["my second string"] and get the data associated with question 2, whether using the number or the string as a key to that data. Is this possible without having to iterating over all the keys while avoiding data duplication?