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.
Here's the sample 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)
My Output:
1
2
3
4
5
count: 5
Required Output:
1
2
3
4
5
count: 5
6
7
8
9
and goes on....