Last active
December 20, 2015 15:09
-
-
Save johl/6152419 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hej!
Mein Python ist etwas rostig... aber müsste das nicht: "data = r.json()" heissen? Damit läuft es bei mir jedenfalls ;)
LG,
Sebastian