range() to a list in Python Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report In Python, the range() function is used to generate a sequence of numbers. However, it produces a range object, which is an iterable but not a list. If we need to manipulate or access the numbers as a list, we must explicitly convert the range object into a list. For example, given range(1, 5), we might want to convert it to [1, 2, 3, 4]. Let's explore various ways to achieve this.Using list() Constructor The simplest and most efficient way to convert a range object into a list is by using the list() constructor. Python r = range(1, 5) a = list(r) print(a) Output[1, 2, 3, 4] Explanation:list() constructor takes the range object as an input and converts it directly into a list.This method is fast, concise, and highly readable.Using List ComprehensionList comprehension provides another efficient and Pythonic way to convert a range object into a list. Python r = range(1, 5) a = [x for x in r] print(a) Output[1, 2, 3, 4] Explanation:The comprehension iterates through each element in the range object.Each element is added to the new list, resulting in the complete conversion.Using Unpacking Operator *The unpacking operator * can unpack the elements of a range object directly into a list. Python r = range(1, 5) a = [*r] print(a) Output[1, 2, 3, 4] Explanation:The * operator unpacks all elements of the range object.These elements are then stored in a new list.Using for Loop (Manual Conversion)A for loop can manually convert a range object into a list by iterating over its elements. Python r = range(1, 5) a = [] for x in r: a.append(x) print(a) Output[1, 2, 3, 4] Explanation:An empty list is initialized.The loop iterates through the range object and appends each element to the list.Using map() map() function, combined with the identity function, can also convert a range object into a list. Python r = range(1, 5) a = list(map(lambda x: x, r)) print(a) Output[1, 2, 3, 4] Explanation:The map() function applies the identity function to each element of the range object.The resulting map object is converted into a list using the list() constructor.Related Articles:Python range() functionPython List methodsList Comprehension in PythonPython For LoopsPython map() function Comment More infoAdvertise with us Next Article Python range() function S Shubham__Ranjan Follow Improve Article Tags : Python python-list Python list-programs Practice Tags : pythonpython-list Similar Reads Convert string to a list in Python Our task is to Convert string to a list in Python. Whether we need to break a string into characters or words, there are multiple efficient methods to achieve this. In this article, we'll explore these conversion techniques with simple examples. The most common way to convert a string into a list is 2 min read Python - Loop Through a Range Looping through a range is an important operation in Python. In this article, we will explore the different ways to loop through a range in Python, demonstrating how we customize start, end, and step values, as well as alternative methods for more advanced use cases like looping through floating-poi 3 min read How to Replace Values in a List in Python? Replacing values in a list in Python can be done by accessing specific indexes and using loops. In this article, we are going to see how to replace the value in a List using Python. We can replace values in the list in several ways. The simplest way to replace values in a list in Python is by using 2 min read Python - Numbers in a list within a given range We are given a list and we are given a range we need to count how many number lies in the given range. For example, we are having a list n = [5, 15, 25, 35, 45, 55, 65, 75] and we are having range lower=20, upper=60 so we need to count how many element lies between this range so that the output shou 4 min read Python range() function The Python range() function returns a sequence of numbers, in a given range. The most common use of it is to iterate sequences on a sequence of numbers using Python loops.ExampleIn the given example, we are printing the number from 0 to 4.Pythonfor i in range(5): print(i, end=" ") print()Output:0 1 7 min read Python range() Method range() function in Python is used to generate a sequence of numbers. It is widely used in loops or when creating sequences for iteration. Letâs look at a simple example of the range() method.Python# Generate a sequence of numbers from 0 to 4 for i in range(5): print(i) Output0 1 2 3 4 Explanation:T 3 min read Like