-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathRestFul.py
More file actions
49 lines (45 loc) · 1.27 KB
/
RestFul.py
File metadata and controls
49 lines (45 loc) · 1.27 KB
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
43
44
45
46
47
48
49
import requests
import json
"""
url='https://jsonmock.hackerrank.com/api/football_matches?'
parameter={'year':2011,'team1':'Barcelona'}
res=requests.get(url,params=parameter)
match=res.json()
#print(match)
#print(type(match))
#print(type(match['data'][0]['team1goals']))
sum_team1=0
for goals in match['data']:
#print(goals)
sum_team1+=int(goals['team1goals'])
#print(sum_team1)
url='https://jsonmock.hackerrank.com/api/football_matches?'
parameter={'year':2011,'team2':'Barcelona'}
res=requests.get(url,params=parameter)
match=res.json()
sum_team2=0
for goals in match['data']:
sum_team2+=int(goals['team2goals'])
print(sum_team1+sum_team2)
#sum=0
#for i in match['data']:
# sum+=match['data']['team1']
#print(sum)
#print(type(content))
url='https://jsonmock.hackerrank.com/api/football_competitions?'
parameter={'year':2011,'name':'UEFA Champions League'}
res=requests.get(url,params=parameter)
matches=res.json()
#print(res.json())
print(matches['data'])
"""
url='https://jsonmock.hackerrank.com/api/football_matches?'
parameter={'year':2011,'competition':'UEFA Champions League','team2':'chelsea'}
res=requests.get(url,params=parameter)
matches=res.json()
#print(res.json())
#print(matches['data'])
sum=0
for goals in matches['data']:
sum+=int(goals['team2goals'])
print(sum)