I’m doing a query to the Alexa API which, for some unknown reason, will occasionally fail. When it does fail, I want to automatically retry the query, up to 10 times.
When it fails, the response returned by the API contains the substring AuthFailure.
What kind of loop can I do that will retry the query until either the response returned does not contain the substring AuthFailure or 10 retries have been attempted?
You could do this with a
forloop.Adjust 10 to whatever number you wish. Better yet, use a constant
define()‘ed elsewhere. This will run until the number of tries is exhausted or until the return value does not contain ‘AuthFailure’.