for i in range(7):
print(i**3)
We have used range here to generate the sequence of numbers.
range(stop)
returns the sequence of numbers up to stop
argument.
range
takes two other arguments as well
- start
- step
range(start, stop[, step])
start
argument tells where to start the sequence from. Defaults to 0.
step
argument tells the increment value between each number in the sequence. Defaults to 1.
Note - range
in Python3 returns a range
object, not list.
Top comments (0)