I do a loop of requests and unfortunately sometimes there happens a server timeout. Thats why I want to check the status code first and if it is not 200 I want to go back and repeat the last request until the status code is 200. An example of the code looks like this:
for i in range(0, len(table)):
var = table.iloc[i]
url = 'http://example.request.com/var/'
response = requests.get(url)
if response.status_code == 200:
data = response.json()
else:
"go back to response"
I am appending the response data of every i, so I would like to go back as long as the response code is 200 and then go on with the next i in the loop. Is there any easy solution?