[Tutor] Dictionary Question

Jason N. nymcity at yahoo.com
Mon May 2 20:56:56 EDT 2016


Thank you all for your responses. 
A quick follow up, what is the best way to make dictionary requests case in-sensitive? For example, "Apple and "apple" should bring back the same dictionary response. Thank you. 

    On Monday, May 2, 2016 6:57 PM, Bob Gailer <bgailer at gmail.com> wrote:
 
 

 
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