9 Réponses
+ 1
SFAH
just observer the value of i with every loop iteration,
i is decreasing , you need to increase the value of i as written by all of us 👍.
+ 3
i = 0
while i < 5:
i -= 1 #bug
+ 3
variable "i" value is initialized zero.
In while loop at end, you wrote i-=1 it should be i+=1 so that 0 can get increment to 5 and break the loop.
+ 1
Ti Ger V2 your loop is infinite loop since the value of "i" will never go beyond 5. Because as everyone have said "i-=1" will decrease the value of loop variable. Which means as the loop will proceed its value will be -1,-2,-3 and so on which is less than 5. Therefore to avoid it you should use "i+=1". This will increase value of "i" like 1,2,3 so on till the condition of loop is satisfied.
- 2
لم افهم
- 2
I don't understand
- 2
Yep i was decreasing not increasing
Thank u all ❤️
- 3
??