Looping over a range of numbers in Python3

asgarzee profile image Zeeshan Asgar ・1 min read
for i in range(7):
Enter fullscreen mode Exit fullscreen mode

We have used range here to generate the sequence of numbers.


returns the sequence of numbers up to stop argument.

range takes two other arguments as well

  1. start
  2. 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.


Editor guide