Sorry I made a mistake. What you are looking for is the step parameter of range()
like this:
for i in range(0,5,2):
intl = i
print(intl)
intn = i+1
print(intn)
print("---------")
Now, for every loop it will skip one number (so i=0, then i=2, then i=4). When modifiying the variable i
within a for loop, you will change the local version of i
that is active in the current loop. Python doesn't actually use i
to get the next item from a itterable, and thus manually changing it doesn't do anything for your loop.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…