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

18th Jun 2021, 1:34 PM
Likhon
Likhon - avatar
2 Answers
+ 2
because while loop never stops.
18th Jun 2021, 1:39 PM
Abhay
Abhay - avatar
+ 1
Then why -(minus) makes a difference
18th Jun 2021, 1:41 PM
Likhon
Likhon - avatar