# Online Python compiler (interpreter) to run Python online.
# Write Python 3 code in this online editor and run it.
def test(i):
n=0
while n<i:
if n==3:
yield 'We reached the limit'
else:
yield n
n=n+1
m=test(24)
print(next(m))
print(next(m))
print(next(m))
print(next(m))
///////
0
1
2
We reached the limit