I'm making a fibonacci sequence. Everytime I deal with Console (on Windows), it runs too fast and suddenly exits for itself.
So I use Time.sleep()
to look what's going on.
Here is the source:
def fibo():
pv1,pv2 = 0,1
while True:
yield pv2
pv1,pv2=pv2,pv1+pv2
import time
f=fibo()
for result in f:
print(result,end=' ')
time.sleep(0.5)
I expected "1 1 2 3 ..." per 0.5 secs but it never works! Without the sleeping method, it runs fine. I think there's something but I'm too ignorant to know why.