for x in range(len(pallets_data_list)):
"""
SOME CODE
"""
if pallets_data_list[x]['data_id'] == 32:
# Go back and search again in for loop
In above code, I have a for loop which is iterating over pallets_data_list. Inside this for loop, if the condition becomes True, I need to go back to for loop and start iterating again from 0. Lets consider that the condition becomes True at x = 20.
To reset x, I am setting it to 0 and then using continue like below:
if pallets_data_list[x]['data_id'] == 32:
# Go back and search again in for loop
x = 0
continue
Using continue, its going back to for loop but x is not reset and starts iterating from 21. Is there any way, I can reset x again back to 0. Can anyone please suggest any good solution. Please help. Thanks