So I have the following generator function:
def gen(n=5):
    for i in range(n):
        n = yield n
for i in gen(3):
    print(i)
The result:
3
None
None
I understand the first result of yield is 3. Because I assigned 3 to function argument n. But where are the None in the second and third yield coming from? Is it because in the for-loop, yield n returns None and this None is assigned to n in this line: n = yield n?
 
     
     
    