Convert list to Python array - Python Last Updated : 17 Apr, 2025 Comments Improve Suggest changes Like Article Like Report We can use a number of approaches to convert a list into a Python array based on the requirements. One option is to use the array module, which allows us to create arrays with a specified data type. Another option is to use the numpy.array() method, which provides more features for working with arraysUsing array() with data type indicator This task can be easily performed using the array() function. This is an inbuilt function in Python to convert to an array. The data type indicator "i" is used in the case of integers, which restricts data type. Python from array import array a = [6, 4, 8, 9, 10] print(str(a)) res = array("i", a) print(str(res)) Output[6, 4, 8, 9, 10] array('i', [6, 4, 8, 9, 10]) Explanation: In array("i", a) "i" indicates that the data type of the array elements will be integers (int). res is the array created from the list a.Using numpy.array()This method uses NumPy's array() function to convert a list into a NumPy array, offering more flexibility and additional functionality for numerical operations. Python import numpy as np a = [6, 4, 8, 9, 10] print(str(a)) res = np.array(a) print(str(res)) Output[6, 4, 8, 9, 10] [ 6 4 8 9 10] Explanation: The numpy.array() function converts the list a into a NumPy array. By default, NumPy will infer the data type (int in this case), but you can specify it explicitly using the dtype argument if needed.Related Articles:Python Built in FunctionsBasics of NumPy ArraysPython NumPyPython Tutorial Comment More infoAdvertise with us Next Article Convert list to Python array - Python manjeet_04 Follow Improve Article Tags : Python Python Programs Python list-programs Practice Tags : python Similar Reads Convert Tuple to Json Array in Python Python's versatility as a programming language extends to its rich data structures, including tuples and JSON. JSON, abbreviation for JavaScript Object Notation, is a lightweight data format used for representing structured data. Moreover, it is a syntax for storing and exchanging data. In this arti 3 min read Convert List to Tuple in Python The task of converting a list to a tuple in Python involves transforming a mutable data structure list into an immutable one tuple. Using tuple()The most straightforward and efficient method to convert a list into a tuple is by using the built-in tuple(). This method directly takes any iterable like 2 min read Convert String List to ASCII Values - Python We need to convert each character into its corresponding ASCII value. For example, consider the list ["Hi", "Bye"]. We want to convert it into [[72, 105], [66, 121, 101]], where each character is replaced by its ASCII value. Let's discuss multiple ways to achieve this.Using List Comprehension with o 2 min read How to Create String Array in Python ? To create a string array in Python, different methods can be used based on the requirement. A list can store multiple strings easily, NumPy arrays offer more features for large-scale data and the array module provides type-restricted storage. Each method helps in managing collections of text values 2 min read Convert a Dictionary to a List in Python In Python, dictionaries and lists are important data structures. Dictionaries hold pairs of keys and values, while lists are groups of elements arranged in a specific order. Sometimes, you might want to change a dictionary into a list, and Python offers various ways to do this. How to Convert a Dict 3 min read Python - List of float to string conversion When working with lists of floats in Python, we may often need to convert the elements of the list from float to string format. For example, if we have a list of floating-point numbers like [1.23, 4.56, 7.89], converting them to strings allows us to perform string-specific operations or output them 3 min read Python | Convert list of tuples into list In Python we often need to convert a list of tuples into a flat list, especially when we work with datasets or nested structures. In this article, we will explore various methods to Convert a list of tuples into a list. Using itertools.chain() itertools.chain() is the most efficient way to flatten a 3 min read Convert List of Lists to Dictionary - Python We are given list of lists we need to convert it to python . For example we are given a list of lists a = [["a", 1], ["b", 2], ["c", 3]] we need to convert the list in dictionary so that the output becomes {'a': 1, 'b': 2, 'c': 3}. Using Dictionary ComprehensionUsing dictionary comprehension, we ite 3 min read Convert Set of Tuples to a List of Lists in Python Sets and lists are two basic data structures in programming that have distinct uses. It is sometimes necessary to transform a collection of tuples into a list of lists. Each tuple is converted into a list throughout this procedure, and these lists are subsequently compiled into a single, bigger list 3 min read Python Json To List JSON (JavaScript Object Notation) is a lightweight data-interchange format widely used in web development and data exchange. In Python, converting JSON to a list is a common task, and there are several methods available to achieve this. In this article, we will explore four simple and commonly used 2 min read Like