'Add item back to for loop
I am working on some code, and I cannot figure out how to create the behavior that I want. I want to iterate through a list, and pull some data. In my real code, the code is designed to pull some data, but the data is posted at different times and not really in a predictable fashion. What I'd like to do is add the iterable back into the list if there is an error.
Example Code
my_list = ['cat', 'dog', 'bird', 'fish']
for animal in my_list:
try:
get.('www.somerandomurl_{}.com'.format(animal))
print("good work!")
except:
add item back to list, try again once the rest of the list is compete
Is there a way to do this? Possibly even telling python to wait for n minutes to try again with the items that had an error
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
