30-Days-Of-Python icon indicating copy to clipboard operation
30-Days-Of-Python copied to clipboard

Bug in code loop example

Open P3ntestoR opened this issue 3 years ago • 0 comments

hey Asabeneh ,

https://github.com/Asabeneh/30-Days-Of-Python/blob/master/10_Day_Loops/10_loops.md on this day you write a example of continue in loop

count = 0
while count < 5:
    if count == 3:
        continue
    print(count)
    count = count + 1

you say about result "The above while loop only prints 0, 1, 2 and 4 (skips 3)." but result is infinite loop after print 2 because you don't add to count anything in if block

count = 0
while count < 5:
    if count == 3:
        count = count + 1
        continue
    print(count)
    count = count + 1

thanks you for share this good resource for learning python .

P3ntestoR avatar Feb 07 '22 14:02 P3ntestoR