0
What is i here? A variable or a list?
3 Antworten
+ 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)