this should work
def find_value(value, lst): for obj in lst: if value in obj.values(): return obj >> find_value("aaa", my_lst) Vince On Thu, Jul 23, 2009 at 9:55 AM, <davidwil...@safe-mail.net> wrote: > hello, > please excuse me, but i would like to understand how dictionaris work. > > for example: > >>> my_lst = [{'code': 'aaa', 'name': 'a name'}, {'code': 'bbb', 'name': 'b > name'}] > >>> my_code = 'aaa' > > > from the above i would like to compare my_code and return the dictionary > which has code == my_code > > dave > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor