How many times the following loop
will run?
>>>i=5
>>>while (i>0):
>>> i=i-1
Answers
Answered by
2
Bro Actually its an error, because i = i - 1 , will be inside while, it should be like this
>>> i = 5
>>> while (i > 0):
i -= 1
>>>
The loop will run 5 times, and you can check it simply by taking a counter variables, like
i = 5
count = 1
while (i > 0):
i -= 1
print(count)
count += 1
Similar questions
Math,
2 months ago
Biology,
2 months ago
English,
5 months ago
Computer Science,
11 months ago
Chemistry,
11 months ago