What does the "i" in the (repeat for "i" from 1 to 10 with step 1) loop block do?

Hi, I have been trying to figure out what the “i” in this block stands for, aswell as what it does, and when it is used.
(repeat for “i” from 1 to 10 with step 1)
Can anyone help me out here?
Best wishes, Rasmus

It might probably the “i” is a variable with parameter that when it is true, it executes the action.

1 Like

Hi @Rasmus_Broe,

@Javier_Montiel is correct that the “i” is a variable; however its function is to store the current number value (which is between 1 & 10, incrementing by 1 with each loop) so that number can be used within the loop.

Here’s an example:

The result is that Fancy Boy counts from 1 to 10, in 10 seconds. You can change the name of “i” to whatever you like:

The result is that the Fancy Boy counts in tens, from 0 to 100 (ie, 0, 10, 20, 30 etc).

Hope this helps! Let me know if you have any further queries about this. If it solves your issue, please mark as Solved.

Geoff @ TechLeap

1 Like

Hi Geoff
Thank you very much for the thorough reply.
Just out of curiosity, do you have any idea what the “i” stands for?
Thank you.

I would have said it’s just a standard substitute we use in text-based programming, and you can easily substitute with j or k or n etc, which is true, however… programming practices - Why do most of us use 'i' as a loop counter variable? - Software Engineering Stack Exchange


1 Like