Python – Convert Range into a List

Convert Range into a List

To convert given range object into a list in Python, call list() builtin function and pass the given range object as argument. list() function returns a new list with the elements from the range object.

The syntax to convert given range object a into a list output is

output = list(a)


In the following example, we take a range object starting at 4, and progressing upto 10 (excluding 10), and convert this range object into a list.

Python Program

#take a range
a = range(4,10)
#convert range object into list
output = list(a)
Run Code Online


[4, 5, 6, 7, 8, 9]


In this tutorial of Python Examples, we learned how to convert a range object into a list using list() builtin function.

⫷ Previous tutorialNext tutorial ⫸