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.
numberis equivalent toiin your C loop, i.e., it is a variable that holds the value of each loop iteration.A simple translation of your Python code to C would result in something along these lines: