Advertisements
Advertisements
Question
What is the purpose of the range() function? Give one example.
Short/Brief Note
Advertisements
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 the stop value (excluding the 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
4shaalaa.com
Is there an error in this question or solution?
