Python range() Function with Examples

Python Range() – This function is used to return a sequence of numbers, for a given range. The common use of it is to iterate ( traverse ) the sequence on a sequence of given numbers using Python loops.


range(startFrom, stopAt, step)

  • startFrom – Represents the start value of the sequence. It is optional.
  • stopAt – represents the next value after the end value of the sequence.
  • step – It is an integer value that denotes the difference between any two numbers in the sequence. It is optional.

Example –

for i in the range (3);

print(i,end=” ”);



0 1 2 

In other words, the range() allows the user to access a series of numbers within a given range. It depends on how many arguments the user is passing right into the function, the user is able to decide where that series of numbers should begin and end, and even how big the difference should be between one number and the next number.

Tags: No tags

Add a Comment

Your email address will not be published. Required fields are marked *