python fibonacci generator

def fib(num):
    a = 0
    b = 1
    for i in range(num):
        yield a
        a, b = b, a + b # Adds values together then swaps them

for x in fib(100):
    print(x)

Here is what the above code is Doing:
1. Define a function that takes a number as an argument.
2. Set the initial values of a and b to 0 and 1.
3. Use a for loop to iterate through the range of the number.
4. Use yield to return the value of a.
5. Set the values of a and b to b and a + b.
6. Use a for loop to iterate through the range of the number.
7. Print the value of x.