range
Report an issueopen_in_new
View sourceopen_in_new
Nightly
·
8.1
·
8.0
·
7.5
·
7.4
A language built-in type to support ranges. Example of range literal:
x = range(1, 10, 3)
Accessing elements is possible using indexing (starts from
0
):
e = x[1] # e == 2
Ranges do not support the
+
operator for concatenation.Similar to strings, ranges support slice operations:
range(10)[1:3] # range(1, 3)
range(10)[::2] # range(0, 10, 2)
range(10)[3:0:-1] # range(3, 0, -1)
Ranges are immutable, as in Python 3.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-03-05 UTC.
[null,null,["Last updated 2025-03-05 UTC."],[],[]]