As BrenBarn says, continue
just skips the rest of the loop and goes on to the next iteration.
But it doesn't matter when var
starts at 95, because that code never gets reached. Let's trace through and see what happens:
var = 95
First loop, items = 0:
since var (95) > 10:
print("passed")
var = var + 1 = 96
Next loop, items = 1
since var (96) > 10:
print("passed")
var = var + 1 = 97
...
100th loop, items = 99
since var (194) > 10:
print("passed")
var = var + 1 = 195
If I change var to like (3) will it just "continue" to the next code block?
No, it continues to the next iteration of the while
loop—meaning it skips over the var = var + 1
part. If you want to break out of the loop and go to the next code block, that's break
rather than continue
.
Now, let's trace through what happens if you start with 3:
var = 3
First loop, items = 0:
since var (3) < 10:
continue # skips to the next loop iteration
Second loop, items = 1:
since var (3) < 10:
continue # skips to the next loop iteration
...
Last loop, items = 99:
since var (3) < 10:
continue # skips to the next loop iteration
Because of the continue
, it never gets to the var = var + 1
, so it just loops 100 times without doing anything.
Which means if you tried to test it with, say, a print(var)
after the loop, it would look an awful lot like it just skipped to the next block of code. But if you put a print(items)
there, you'll see that it's 99, not 0. Or, if you print
something before continue
, you'll see it happen 100 times.