returning values of a particular key from a dictionary

Paul Rubin http
Fri May 1 11:00:42 CEST 2009


Saurabh <phonethics at gmail.com> writes:
> arr = ({'x':'1', 'y':'a'}, {'x':'2', 'y':'b'}, {'x':'3', 'y':'c'})
> print foo(arr, 'y')
> ['a','b','c']

print list(a['y'] for a in arr)



More information about the Python-list mailing list