[Tutor] Dictionary Question

Bob Gailer bgailer at gmail.com
Mon May 2 18:57:53 EDT 2016


On May 2, 2016 5:27 PM, "Jason N. via Tutor" <tutor at python.org> wrote:
>
> Hello,
> Wanted to ask if its possible to have a dictionary that can be looked up
by either values?
> For example,
> mydic = {"A: "Apple", "B": "Banana"}When user inputs "A" I want "Apple"
to come. But if the user enter "Apple" I want "A" to respond.
I think this would depend on how big the data set is and how often you want
to look things up.
Two other Solutions:
Create a class which internally manages two dictionaries.
If things are really big create a database using for example sqlite.


More information about the Tutor mailing list