returning values of a particular key from a dictionary

S

Saurabh

arr = ({'x':'1', 'y':'a'}, {'x':'2', 'y':'b'}, {'x':'3', 'y':'c'})
print foo(arr, 'y')
['a','b','c']

I can write the function foo to return ['a','b','c'].
Is there some 'automatic'/built-in way to get this in Python ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top