Reputation: 25
I am using Python 3.8 and I was wandering if is there any way to make two steps in a one step for loop like this:
for i in range(15):
if i == 2:
# make two steps
else:
#continue normaly
Upvotes: 1
Views: 186
Reputation: 191738
Manipulate the generator manually
gen = iter(range(15))
while True:
try:
i = next(gen)
if i ==2:
next(gen)
continue
else:
pass
except: StopIteration
break
Upvotes: 1