Search code examples
language-agnosticloopsprogramming-languages

Increasing the value of a for loop counter


Is there any programming language/script who won't allow increasing the counter for an FOR loop inside the loop?

For example:

for(int i = 0; i < 10; i++) 
{
    i++;
    print i
}

Output: 1 3 5 7 8 9

Solution

  • Not sure I fully understand your question but,

    in python :

    for i in range(10):
        print i
        i+=1  #if I print i now I will get i+1, 
    

    You will return the same result as :

    for i in range(10):
        print i
    

    i.e :

    0 1 2 3 4 5 6 7 8 9