0
Can someone tell me how does this program works
i = 0 while True: i = i +1 if i == 2: print("Skipping 2") continue if i == 5: print("Breaking") break print(i) print("Finished")
2 Antworten
+ 2
i starts at 0
and increases by 1.
since it's not 2 or 5 nothing special happens.
i gets printed: 1
i increases by 1.
since it is equal to 2 it prints: Skipping 2 and starts at the begining of the while-loop.
i increases by one since it is not equal to 2 or 5 nothing special happens
i gets printed: 3
(this reapeats until i reaches 5...)
since i is equal to 5 it prints: Breaking and leaves the while-loop
in the end Finished gets printed.
hope this hepls.
happy coding! 😄
+ 1
Thank you bro