You are here: Home / Topics / Range() function in Python

Range() function in Python

Filed under: Python on 2022-08-05 15:16:11

Range in python is a in-build function which return the collection of sequential numbers started from the 0 by default up to specified range. It uses in python programming where we want to generate some sequential numbers.

Example -

range(4) will give 0,1,2,3
range(1,5) will give 1,2,3,4
range(5,1) will give nothing

Program -

t=range(4)
print(list(t))
t=range(1,5)
print(list(t))
t=range(5,1)
print(list(t))
t=range(4,4)
print(list(t))

for i in range(2):
print("Text")

Output of this program is:

[0, 1, 2, 3]
[1, 2, 3, 4]
[]
[]
Text
Text
About Author:
P
Pritvik     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.