I have been looking at new tutorials (a bit more advanced than what I normally watch) and they use the letter “i” and “for” in their code. They never explain it, I guess because it sort of like an if-then statement? most of the time, it’s used when an array is involved. I checked documentation, and the forums but didn’t see anything about it. again, I am curious what i and for actually do/mean. Any help is appreciated!
old programming convention, stands for “index” or “iterator”. a non-descriptive name, I prefer to use fitting ones where available, like “child” when dealing with children.
for child in get_children():
It’s the name of the iterating variable, you could give it any name you want.
It’s a programming convention. The for loop is basically “iterate through this N times”, and then you’d give it a counter (which is where the ‘i’ comes in).
So if I were saying, for example, I want to count up to 10. Then it’s 1, 2, 3, …, 9, 10.
I can do that as a for loop. The for would go from 1 to 10, and the counter would be stored with your index variable (the ‘i’ here). Then at each iteration, you get the current index and print that out, which gives you 1 through 10.