0
respostas

Na aula quando eles executam o código a resposta diverge da minha.

import requests

link = 'https://guilhermeonrails.github.io/api-restaurantes/restaurantes.json'
response = requests.get(link)
print(response)

if response.status_code == 200:
dados_json = response.json()
dados_restaurante = {}
for item in dados_json:
nome_restaurante = item['Company']
if nome_restaurante not in dados_restaurante:
dados_restaurante[nome_restaurante] = []

        dados_restaurante[nome_restaurante].append({
            'item': item['Item'],
            'price': item['price'],
            'description': item['description']
        })

else:
print(f'O erro foi {response.status_code}')

print(dados_restaurante['McDonald’s'])

resposta:

(venv) PS C:\Users\Gustavo\Documents\Projetos\OSaborExpress-Venv> python app.py
<Response [200]>
[{'item': 'Hamburger', 'price': 32.42, 'description': 'Uma explosão de sabores em cada mordida.'}]