One way to do this is to simply create two dictionaries at the same time. Each dictionary is the mirror of each other. dict1={'aa':1, 'bb':2] dict2={1:'aa', 2:'bb'] Not very elegant, but it's simple. This assumes that your dictionary is one-to-one. For example, this dictionary would not work: dict1=['aa':1, 'bb':1]
Yours, Noah > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of A > Sent: Monday, March 25, 2002 2:16 PM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; > [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: How to get a key from dictionary? > > > Hi, > Is there a possibility to get, from a dictionary, a key according to a > value ? > For example > I have a dictionary > > dict={'aa':1,'bb':2} > > and > dict['aa'] > is 1 > > But how can I for value 1 find out key? (That is here 'aa') > > Thank you for help > Ladislav > > > _______________________________________________ > ActivePython mailing list > [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > _______________________________________________ ActivePython mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs