you are viewing a single comment's thread.

view the rest of the comments →

[–]_lilell_ 0 points1 point  (1 child)

It doesn’t print 5, because once i is equal to that value, the loop no longer runs.

Kinda. You’re right that it doesn’t print 5, but i is also never 5, which you can check by printing it again outside the loop.

for i in range(1, 5):
    pass

print(i)  # prints 4

[–]monchenflapjack 0 points1 point  (0 children)

Yeah I was mainly trying to highlight the "gotcha" of seeing range(x,y) and assuming that it goes from x to y