I’d like to know how I can somehow stay on one Element until the next loop cycle in a for loop. here’s a code example:
for element in numbers: try: ... except: # It should stay on this element for the next time pass
So as example, I have
numbers = ['apple', 'banana', 'peach']
Now I’m on the element Banana as example, and If that error comes up, It should just stay on banana until the next cycle, so the expected output would be: apple, banana (error), banana (now It tries again), peach
I can explain In more detail If needed.
Use a while loop to iterate on the indexes:
i = 0 while i < len(numbers): element = numbers[i] try: ... i+=1 except: # It should stay on this element for the next time pass