title: Need clarification on the function of "return" and "break" in this code
body: <p>i wrote this python code in python3.</p>
  
  <pre><code>def fibonacci(n): #generator function
     a, b, counter = 0, 1, 0
     while True:
        if (counter &gt; n): 
           return
        yield a
        a, b = b, a + b
        counter += 1
  f = fibonacci(5) #f is iterator object
  </code></pre>
  
  <p>in the above code if i replace the return with the "break" statement, then it still work fine.</p>
  
  <p>I am looking for more clarification on the usage of "Return" vs "Break" from this particular code perspective.</p>