Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import requests
- def getrelevantfood(city,maxcost):
- url = lambda i :"http://jsonmock.hackerrank.com/api/food_outlets?city={}&page={}".format(city,str(i))
- r=requests.get(url(1))
- r=r.json()
- #print(json.dumps(r,indent=2))
- total=r['total_pages']
- ans= []
- for i in range(total):
- for item in r["data"]:
- if item["city"]==city and item['estimated_cost']*2<=maxcost:
- ans.append(item['name'])
- return ans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement