wiz-icon
MyQuestionIcon
MyQuestionIcon
2
You visited us 2 times! Enjoying our articles? Unlock Full Access!
Question

What is the purpose of range() function? Give one example.

Open in App
Solution

The range() function is a built-in function of Python. It is used to create a list containing a sequence of integers from the given start value to stop value (excluding stop value). This is often used in for loop for generating the sequence of numbers.

​Example:
for num in range(0,5):
print (num)


OUTPUT:
0
1
2
3
​4

flag
Suggest Corrections
thumbs-up
13
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Arithmetic Mean
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon