DEV Community

DDSRY
DDSRY

Posted on • Updated on

Why does for i in range(1,3): only loop two times instead of three times in Python?

Why does for i in range(1,3): only loop two times instead of three times in Python Programming Language By DDSRY?

  • The range() function only does numbers from the first to the last (not including the last).
  • So it stop at two, not three, in the above.
  • This turn out to be the most common way to do this kind of loop.

Read more..

Top comments (0)