Fiz a alteração sugerida mas ainda retornou com o mesmo problema.
Segue o código:
import requests def f_answers(): for ticket_number in range (0, 1000): no_data1 = '{"error":"Ticket not found"}' no_data2 ='[]' url = 'https://api.tiflux.com/api/v1/tickets/{}/answers?offset=1&limit=200'.format(ticket_number) headers = { 'Content-Type': 'application/json', 'Authorization': 'Basic {token}' } answers = requests.get(url, headers = headers) if answers.text == no_data1: print('O ticket nº{} não existe.'.format(ticket_number)) elif answers.text == no_data2: print('O ticket nº{} não há respostas.'.format(ticket_number)) else: file_json = open('/home/trade/_business_intelligence/Indicadores/infra_sustentacao/json/_tiflux/_answers/_answers.json', 'a', encoding = 'utf-8') file_json.write(answers.text.replace('][', '')) url = 'https://api.tiflux.com/api/v1/tickets/{}/answers?offset=1&limit=200'.format(ticket_number) answers = requests.get(url, headers = headers) f_answers()