Question: ```
a = 0
b = 1
print a
print b
for i in range (102):
    c = a + b
    a = b
    b = c
    print c

print "The 103rd number is", c

```

I don't understand how the for statement works. I understand everything except how the program continues till the 103rd element and understands that it has to add the last two numbers to get the next number. I understand that a is equal to b and b is equal to c. 

Is it because after adding c, it changes the vales of a and b then goes back to the for statement? And that is where I am confused. What does the program do next?

Does it go back to the for statement to check which (term)/element this is to make sure it is less then 102. 

Also when I specify the range to be 102 does it do the action once and then 102 times more basically list the number 103 times) or does it do it 102 times)?

What I am basically asking is if I need to find the 103rd element why do i specify range=102, not range =103

Answer: 
Let's expand the for loop and see what happens:

```
a = 0    
b = 1     # this is the first fibonacci number

# First iteration of for loop
c = a + b # c is now 1, the second fibonacci number
a = b     # a is now 1
b = c     # b is now 1

# Second iteration
c = a + b # c is now 2, the third fibonacci number
a = b     # a is now 1
b = c     # b is now 2

# Third iteration
c = a + b # c is now 3, the fourth fibonacci number
a = b     # a is now 2
b = c     # b is now 3

# Fourth iteration
c = a + b # c is now 5, the fifth fibonacci number
a = b     # a is now 3
b = c     # b is now 5

# Remaining 98 iteration omitted

```

You see that after 4 iterations we have in `c` the 5:th fibonacci number. After 102 iterations `c` will hold the 103:d fibonacci number. That is why you are using `range(102)` and not `range(103)`. If you wanted your fibonacci series to start with 0 ([as it sometimes does](http://en.wikipedia.org/wiki/Fibonacci_number)), i.e. `0, 1, 1, 3, 5`, you would need to use `range(101)`.

The python for loop iterates over a sequence until the sequence is exhausted, or the for loop is prematurely exited with the `break` statement. `range(5)` creates a list of 5 elements: `[0, 1, 2, 3, 4]`, which, when used with the for loop, causes it to repeat 5 times. The loop body in the following example is therefore evaluated 5 times:

```
sum = 0

for i in range(5):
  sum = sum + i

print sum

```

We just calculated the fifth [Triangle number](http://en.wikipedia.org/wiki/Triangular_number): 10 

More on python for loops: 
<https://wiki.python.org/moin/ForLoop>
There are infinite uses of the `for` statement, for in your case, it just does whatever in it for 102 times. So, **in your specific case**, the `for` statement does...

```
c = a + b
a = b
b = c
print c

c = a + b
a = b
b = c
print c

c = a + b
a = b
b = c
print c

# ... (99 more times)

```

and when it is done, the program finishes with `print "The 103rd number is", c`, which you know what is happening.