IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

range

Defines Mojo's built-in range() function.

In Mojo, ranges are values, not loop constructs, generators, or lists. Every range is a half-open interval, [start, end).

The stand-alone range() function constructs zero-based, sequential, and strided ranges.

range() is built in. You don't need to import it.

Functions

  • range: Returns the integer sequence [0, end).