Is it possible to increment iterator in loop in Python? -


i increment iterator in loop in python. code below:

for in range(0,10):        print(i, end="")     if % 3 == 0:         += 2     else if % 3 == 0:         += 3 

in such way output of code is:

0123456789 

but should different. thanks.

i reassigned @ every iteration; that's how for loop works. if want skip every second number (i.e. iterate in steps of 2), you'll need this:

for in range(0, 10, 2):     print(i, end="") 

that third parameter of range function, called step, determines i incremented in each iteration.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -