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")

30th Aug 2019, 5:07 PM
Prakruth Reddy
Prakruth Reddy - avatar
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! 😄
30th Aug 2019, 5:30 PM
Anton Böhler
Anton Böhler - avatar
+ 1
Thank you bro
30th Aug 2019, 5:40 PM
Prakruth Reddy
Prakruth Reddy - avatar