In Python, how does a for loop with `range` work?

Viewed 80089
for number in range(1,101): 
    print number

Can someone please explain to me why the above code prints 1-100? I understand that the range function excludes the last number in the specified range, however, what is the 'number' part of the syntax?

I am more used to C++ & Java where I'd write the code like:

for (i = 1; i < 101; i++) {
   System.out.println(i);
   i++;
}

So what exactly is 'number'? I'm sure i'm looking too far into this and there is a simple question.

6 Answers
Related