0
What is i here? A variable or a list?
3 Answers
+ 2
farid mumtaz hi,
đ In your sample code first line
def countdown(): is for creation of the user-defined function which is used for countdown the number
đ second line i = 5 is used for declare an variable with initial value 5
đ while i >0: is an while loop creation in which value of i is decreasing by 1
đ then again call of the countdown function which print the yield values from last statement.
đ so this way your program is run here i is an variable with initial value 5
Have these đ đ đ đ đ
+ 1
DishaAhuja thanks đ
0
def countdown():
i=5
while i > 0:
yield i
i -= 1
for i in countdown():
print(i)