Answer the question
In order to leave comments, you need to log in
How to tell a loop to go back a few positions?
Hello. How to tell the loop to go back a few positions and continue from there?
Here is an example of what I want to do:
list_1 = ['1','2','3','4','5']
a = '4'
for i in list_1:
if a == '4' and i == '4':
print(i)
# например здесь я хочу чтобы цикл вернулся на позицию, где i = '2'. Как такое можно сделать?
Answer the question
In order to leave comments, you need to log in
i = 0
while i < len(list_1):
v = list_1[i]
i += 1
...
if a == '4' and v == '4':
i = 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question