| <html devsite> |
| <head> |
| <meta name="project_path" value="/_project.yaml"> |
| <meta name="book_path" value="/versions/6.0.0/_book.yaml"> |
| </head> |
| <body> |
| |
| <h1 class="page-title" id="modules.range">range</h1> |
| |
| <!-- {% raw %} --> |
| |
| A language built-in type to support ranges. Example of range literal:<br><pre class=language-python>x = range(1, 10, 3)</pre>Accessing elements is possible using indexing (starts from <code>0</code>):<br><pre class=language-python>e = x[1] # e == 2</pre>Ranges do not support the <code>+</code> operator for concatenation.Similar to strings, ranges support slice operations:<pre class=language-python>range(10)[1:3] # range(1, 3) |
| range(10)[::2] # range(0, 10, 2) |
| range(10)[3:0:-1] # range(3, 0, -1)</pre>Ranges are immutable, as in Python 3. |
| |
| |
| |
| </body> |
| </html> |
| |
| <!-- {% endraw %} --> |