What's the meaning of 'i' in for loop?

In almost every programming language, they use variable i when they explain for loop. Like,

for i in 'string':


for(var i ; i<100 ; i++) {


Does it mean anything? Or just a variable with no meaning?

I couldn't find any information about this in google search.

2 answers

  • answered 2018-04-17 05:50 MaholeycowDev

    it is just a common practice. Many people when learning see i being used as a variable name. But that's all it is. It is just a name that could be anything, you could us any other sequence of characters!

  • answered 2018-04-17 05:50 Tim Weber

    You have given two different example.

    For the first one

    for i in 'string': print(i)

    For this one, the variable 'i' is the variable where the value will be put from your parameter (here 'string'). If i gave an array as parameter for instance, each value of array will be put in 'i', step by step (element [0], then element[1], etc...).
    Note that this is a simplified view of this question and it doesn't work exactly like that for the program. But you can understand it as it.

    For the second one

    for(var i ; i<100 ; i++) {

    You declare explicitly a variable to be used. This declared will be used by the loop, incrementig by the step you had defined until it reaches limit you also defined.

    It is slightly the same thing for both example. Hope i explain well