Increments in 'for' loops


#1

how exactly do i change the increments of numbers when using 'For loops' ?


#2

by typing it to i += number.


#3

There are a couple of ways.
Probably the most simple and intuitive way is to change the value of the counting variable like you'd do anywhere else.
Say your counting variable is i then it would be i = i + x meaning the new value of i is the old value of i +x. The rest are pretty much shortcuts for example:

If you want to increment by 1 (which is pretty common) you can use i++ or ++i. The difference is that one first determines the value and then increments and the other one first increments and then determines the value. As we don't use the value here they're both suitable to increase by 1.

If 1 is simply not enough or adding is not what you want you can use i operator = x for example as @netblaster88808 has shown i+=number or maybe i/=2, i*=4, i-=3 aso.


#4

:slight_smile: Got it and it is cool.