title: Return from a while loop without exiting it python
body: <p>I know it is not possible. Return will exit it. Is there a way to make it possible. I have while loop and it counts the values. I want to return the value from the while loop and use it for further processing and get back to the while loop again and continue where it stopped. I know the return will exit the loop. How to make it possible.</p>
  
  <p>Here's the sample code:</p>
  
  <pre><code>import datetime
  import time
  def fun2(a):
      print("count:", a)
  def fun():
      count = 0
      while 1:
          count = count+1
          time.sleep(1)
          print(count)
          if count == 5:
              return count
  a = fun()
  fun2(a)
  </code></pre>
  
  <p>My Output:</p>
  
  <pre><code>1
  2
  3
  4
  5
  count: 5
  </code></pre>
  
  <p>Required Output:</p>
  
  <pre><code>1
  2
  3
  4
  5
  count: 5
  6
  7
  8
  9
  and goes on....
  </code></pre>