-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathprocedural-solution.py
executable file
·38 lines (30 loc) · 1.02 KB
/
procedural-solution.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
#!/usr/bin/env python3
# my_criteria='Gout'
# criteria_len=len(my_criteria)
# name="Nom"
# name_len=len(name)
# names=[]
# criteria_values=[]
# with open("beer_list.json",'r') as dataset:
# for line in dataset:
# line=line.strip()
# if line[1:name_len+1]==name:
# names.append(line[name_len+4:-1])
# elif line[1:criteria_len+1]==my_criteria:
# criteria_value=line[criteria_len+4:-1]
# if criteria_value== 'null':
# criteria_value=0
# criteria_values.append(float(criteria_value))
# ind_max=criteria_values.index(max(criteria_values))
# print(names[ind_max],criteria_values[ind_max])
import json
with open('beer_list.json', 'r') as f:
beer_dict = json.load(f)
criteria="Gout"
criteria_value=0
for beer in beer_dict:
beer_criteria_value=beer[criteria]
if beer_criteria_value != None and float(beer_criteria_value) > criteria_value:
name=beer["Nom"]
criteria_value=float(beer[criteria])
print(name,criteria_value)