-
Notifications
You must be signed in to change notification settings - Fork 1
/
food_delivery.py
43 lines (32 loc) · 1015 Bytes
/
food_delivery.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import json
import operator
from pprint import pprint
def order_food(name):
deliveroo = {}
glovo = {}
justeat = {}
result = {}
with open('foods/deliveroo.json') as json_data:
deliveroo = json.load(json_data)
# pprint(deliveroo)
with open('foods/glovo.json') as json_data:
glovo = json.load(json_data)
# pprint(fedora)
with open('foods/justeat.json') as json_data:
justeat = json.load(json_data)
# pprint(justeat)
if name in deliveroo:
result.update(({"deliveroo": deliveroo[name]}))
else:
result.update(({"deliveroo": -1}))
if name in glovo:
result.update(({"glovo": glovo[name]}))
else:
result.update(({"glovo": -1}))
if name in deliveroo:
result.update(({"just eat": justeat[name]}))
else:
result.update(({"just eat": -1}))
result = sorted(result.items(), key=operator.itemgetter(1), reverse=True)
key, value = result.pop()
return key, value