I have list lst = [1, 2, 3, 4, 5, 6, 3, 5, 3] and to every iteration, where elem == 3 I want to print strings before that, while elem not is 3 again.
I want to get
2 3:
0 1
1 2
6 3:
3 4
4 5
5 6
8 3:
7 5
But I don't know, how to go to previous string
for i, el in enumerate(lst):
if lst[i] == 3:
print i, el
i -= 1
But it's inly elem-1