Python for loop

In Python, the for loop works differently.If we try to modify the loop iterator variable, it will be simply skipped and iterator will continue from its next value irrespective of the modification.

So in case if we need to modify the loop iterator value in our logic, we have to choose while loop. for loop cannot be used in this scenario. Here is the code snippet to see it in action:

for i in range(1,10):
if i==3:
print i
Categorized as Python

By Chaitanya

I am a family man, perpetual learner, coffee drinker, dessert eater and Happiness Engineer at Automattic. I also read, write, move, and meditate.

Leave a Reply