diff --git a/espn_api/basketball/team.py b/espn_api/basketball/team.py index d0cee3b9..f38e20fe 100644 --- a/espn_api/basketball/team.py +++ b/espn_api/basketball/team.py @@ -48,11 +48,11 @@ def _fetch_schedule(self, data): '''Fetch schedule and scores for team''' for match in data: if 'away' in match.keys(): - if match['away']['teamId'] == self.team_id: + if match.get('away', {}).get('teamId', -1) == self.team_id: new_match = Matchup(match) setattr(new_match, 'away_team', self) self.schedule.append(new_match) - elif match['home']['teamId'] == self.team_id: + elif match.get('home', {}).get('teamId', -1) == self.team_id: new_match = Matchup(match) setattr(new_match, 'home_team', self) self.schedule.append(new_match)