I am trying to understand the flow of control while defining a generator.
def countdown(num)
    print('Starting')
    while num > 0:
        yield num
          num -= 1
val = countdown(5)
when I call next(val), Starting gets printed followed by the number 5
but in the subsequent calls only the number gets printed. why am I not seeing Starting? and why does it show an error when I call next(val) more than 5 times? Any help in understanding the control flow will be much appreciated
 
     
     
     
    