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 M 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 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 Like