I am trying to access a dictionary containing MLB standings data from an API and having trouble accessing the keys/value pairings.
Data:
{200: {'div_name': 'American League West',
'teams': [{'div_rank': '1',
'elim_num': '-',
'gb': '-',
'l': 26,
'league_rank': '6',
'name': 'Seattle Mariners',
'sport_rank': '11',
'team_id': 136,
'w': 28,
'wc_elim_num': '-',
'wc_gb': '-',
'wc_rank': '-'}
I have tried:
for division in standings[200]:
for team in division['teams']:
print(team)
Output:
TypeError: string indices must be integers, not 'str'
New contributor
Nick Tetzlaff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.