What is i here? A variable or a list? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is i here? A variable or a list?

31st May 2019, 6:24 PM
mumtaZ
mumtaZ - avatar
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 🍎 🍎 🍎 🍎 🍎
31st May 2019, 7:18 PM
DishaAhuja
DishaAhuja - avatar
+ 1
DishaAhuja thanks 😊
31st May 2019, 9:13 PM
mumtaZ
mumtaZ - avatar
0
def countdown(): i=5 while i > 0: yield i i -= 1 for i in countdown(): print(i)
31st May 2019, 6:28 PM
mumtaZ
mumtaZ - avatar