0
but if I write i += 1 the result is infinite, why?
def countdown (): i = 5 while i > 0: yield i i -= 1 for i in countdown (): print(i) >>> 1 2 3 4 5
2 Answers
+ 2
because while loop never stops.
+ 1
Then why -(minus) makes a difference
def countdown (): i = 5 while i > 0: yield i i -= 1 for i in countdown (): print(i) >>> 1 2 3 4 5