0
Is countdown (), сreated 3 lists, because of cycle "for"'?
def countdown(i): while i > 0: yield i i -= 1 for i in countdown(3): print(list(countdown(3))) output : [3, 2, 1] [3, 2, 1] [3, 2, 1] =================== def countdown(i): while i > 0: yield i i -= 1 for i in countdown(3): print(list(countdown(i))) output : [3, 2, 1] [2, 1] [1]
1 Réponse
+ 2
In for statement you shouldn't write countdown(i) cause it executes this method again so this is why you're getting that output.
In for statement just write print(i)