[Tutor] Dictionary Question

isaac tetteh itetteh34 at hotmail.com
Mon May 2 17:55:29 EDT 2016


For some reason i cant find reply all . But try this 
for key, value in mydic.items():
      If A==value:
           Print key
Nb: use iteritems() if using python2

Sent from my iPhone

> On May 2, 2016, at 4:29 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.
> Please let me know the best way to handle this type cause instead of just created duplicate entries to cover all possibilities. Thank you.
> _______________________________________________
> 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