- 2

i=4 ,while i>=0,print(i),print i-1

how we get 4 ans ?????

7th Sep 2018, 10:35 AM
Bhaskar Kumar
Bhaskar Kumar - avatar
4 Respuestas
+ 3
Could you please post the real code? Your code in the title seems like semi code and would be an endless loop were you print 4 and 3 in every iteration.
7th Sep 2018, 10:39 AM
Matthias
Matthias - avatar
+ 2
Ok, so you start with 3 and enter the loop as long as i is greater or equal to zero. As you are decrementing i by 1 in every iteration, you will have 4 iterations. And in every iteration you also print the current i, so that's why you get 4 outputs. 3 2 1 0
7th Sep 2018, 10:45 AM
Matthias
Matthias - avatar
+ 1
thanks Matthias...
7th Sep 2018, 10:48 AM
Bhaskar Kumar
Bhaskar Kumar - avatar
0
sory....the code is: i=3 while i>=0: print(i) i=i-1
7th Sep 2018, 10:43 AM
Bhaskar Kumar
Bhaskar Kumar - avatar