[Tutor] Dictionary Question

isaac tetteh itetteh34 at hotmail.com
Mon May 2 21:18:03 EDT 2016


If only I understand what you mean. You can just make all the values in the dictionary lower, upper or capitalized. Then if you want take an input or whatever you want to do with it just use .lower() or .upper() or .capitalized() to convert it to what is in the dictionary. Maybe someone has a better way to do it :) 


Sent from my iPhone

> On May 2, 2016, at 7:59 PM, Jason N. via Tutor <tutor at python.org> wrote:
> 
> 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.
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list