Advertisement
Iam_Sandeep

Untitled

Aug 15th, 2022
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import json
  2. import requests
  3. def getrelevantfood(city,maxcost):
  4.     url = lambda i :"http://jsonmock.hackerrank.com/api/food_outlets?city={}&page={}".format(city,str(i))
  5.     r=requests.get(url(1))
  6.     r=r.json()
  7.     #print(json.dumps(r,indent=2))
  8.     total=r['total_pages']
  9.     ans= []
  10.     for i in range(total):
  11.         for item in r["data"]:
  12.             if item["city"]==city and item['estimated_cost']*2<=maxcost:
  13.                 ans.append(item['name'])
  14.     return ans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement