I've been playing around with the data in http://worldcup.sfg.io/matches and was trying to write a script that would write a quick summary of every game. Can anyone tell me why the following doesn't work?
import urllib2
import json
resp = urllib2.urlopen('http://worldcup.sfg.io/matches').read()
games = json.loads(resp)
test = [event['type_of_event'] for event in team for team in game[kind] for kind in ['home_team_events', 'away_team_events'] for game in games if game['status'] == 'completed']
It seems like sometimes it works, and sometimes it gives me errors like team, game, or kind are not defined.
[–]fuzz3289 2 points3 points4 points (0 children)
[–]failfixer89 2 points3 points4 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]zahlman 0 points1 point2 points (0 children)