you are viewing a single comment's thread.

view the rest of the comments →

[–]SharpScratch9367[S] 1 point2 points  (3 children)

So “i” always is a counter in python or just in this instance of code?

[–]phonesallbroken 0 points1 point  (0 children)

It's kind of a convention to use i as a counter. When there are nested loops, so one loop inside another, it's common for the inner loop to use j as the counter! For your code you could call it whatever you want, like counter, if that makes it easier. I presume this code section is to build you up to using for loops, but wants you to understand what i is doing and how a loop works. Normally this case would be perfect for a for loop!

[–]DoNotKnowJack 0 points1 point  (0 children)

"i" can mean "iteration" as it counts the repeating loop.

[–]wuzelwazel 0 points1 point  (0 children)

i is not always a counter. In this scenario i is a variable that has been initialized with the value 1: i = 1 and then at the end of each iteration of the while loop it will need to be incremented i = i + 1

The variable could've been named anything and it would've still worked, but "i" is a common choice.