returning one value from a dict key with multiple values in python
Question: I am trying to return "runnerName" from the following dict:

    
    
    {u'marketId': u'1.112422365',
     u'marketName': u'1m Mdn Stks',
     u'runners': [{u'handicap': 0.0,
                   u'runnerName': u'La Napoule',
                   u'selectionId': 8095372,
                   u'sortPriority': 1},
                  {u'handicap': 0.0,
                   u'runnerName': u'Swivel',
                   u'selectionId': 701378,
                   u'sortPriority': 2},
                  {u'handicap': 0.0,
                   u'runnerName': u'Deanos Devil',
                   u'selectionId': 8100420,
                   u'sortPriority': 3},
                  {u'handicap': 0.0,
                   u'runnerName': u'Bishan Bedi',
                   u'selectionId': 8084336,
                   u'sortPriority': 4},
                  {u'handicap': 0.0,
                   u'runnerName': u'In Seine',
                   u'selectionId': 8199415,
                   u'sortPriority': 5},
                  {u'handicap': 0.0,
                   u'runnerName': u'Needs The Run',
                   u'selectionId': 8199416,
                   u'sortPriority': 6},
                  {u'handicap': 0.0,
                   u'runnerName': u'Appellez Baileys',
                   u'selectionId': 8148513,
                   u'sortPriority': 7},
                  {u'handicap': 0.0,
                   u'runnerName': u'Jessy Mae',
                   u'selectionId': 7652545,
                   u'sortPriority': 8},
                  {u'handicap': 0.0,
                   u'runnerName': u'Redy To Rumble',
                   u'selectionId': 7366163,
                   u'sortPriority': 9}]}
    

I have tried many different ways but cannot figure out how to access a value
from a key with multiple values.


Answer:   1. You can use list comprehension, like this, to retrieve the runner names from the dictionary of runners.
    
        print [runner["runnerName"] for runner in runners_dict["runners"]]
    

  2. Or you can use [`operator.itemgetter`](http://docs.python.org/2/library/operator.html#operator.itemgetter), like this
    
        from operator import itemgetter
    print map(itemgetter("runnerName"), runners_dict["runners"])
    

**Output**

    
    
    [u'La Napoule', u'Swivel', u'Deanos Devil', u'Bishan Bedi', u'In Seine',
     u'Needs The Run', u'Appellez Baileys', u'Jessy Mae', u'Redy To Rumble']
    

