Skip to content

Instantly share code, notes, and snippets.

@johl
Last active December 20, 2015 15:09
Show Gist options
  • Save johl/6152419 to your computer and use it in GitHub Desktop.
Save johl/6152419 to your computer and use it in GitHub Desktop.
import requests
def count(data, item):
return map(lambda x: x['item'], data).count(item)
r = requests.get("http://melon.meatloaf.ml/api/all")
data = r.json()
meatloafCount = count(data, 'meatloaf')
melonCount = count(data, 'melon')
print 'At OHM2013, %d meatloafs and %d melons were eaten.' % (meatloafCount, melonCount)
@sdraxler
Copy link

sdraxler commented Aug 8, 2013

Hej!

Mein Python ist etwas rostig... aber müsste das nicht: "data = r.json()" heissen? Damit läuft es bei mir jedenfalls ;)

LG,
Sebastian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment