New course! Every coder should learn Generative AI!
Try a free lesson0
why is there a 6?
i = 0 while i < 6: i += 1 if i == 3: continue print(i) 1 2 4 5 6
3 Answers
+ 3
i is increased before you print it out.
swap i += 1 and the print(i) and observe.
+ 3
The while loop condition is tested only at the beginning of each loop. If the condition is true, then the loop statements are executed. Then, after the statements are executed, execution returns to the top of the loop and it checks again.
+ 1
Thanks, everybody. I made a mistake when I did the math in my head. But pen and paper helped me realize