r/pythonhelp • u/helpneed123 • Sep 24 '21
I cannot understand this basic code
i=0
while i < 6:
i += 1
if i == 3 :
continue
print(i)
I know the answer is 6, but how?
It says it is adding the i value by 1.
Also, why is the third line important
Please help. I am trying to study for my exam
2
Upvotes
1
u/[deleted] Sep 24 '21
It's looping through a range from 0 until 6, at which point the while loop ends and the code continues. The next line is print i, which is 6.