Prerequisite: List in Python
As we know Array is a collection of items stored at contiguous memory locations. In Python, List (Dynamic Array) can be treated as Array. In this article, we will learn how to initialize an empty array of some given size.
Let’s see different Pythonic ways to do this task.
Method 1 –
list1 =  * size list2 = [None] * size
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [None, None, None, None, None, None, None, None, None, None] ['A', 'A', 'A', 'A', 'A'] 
Method 2 – Use loops just like C and assign the size.
a = [0 for x in range(size)] #using loops
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [[None, None], [None, None]]
Method 3 – Using Numpy to create empty array.
[None None None None None] [[None None None None None] [None None None None None]]
- Best way to initialize empty array in PHP
- Python | Initialize list with empty dictionaries
- Different ways to Initialize all members of an array to the same value in C
- Initialize Matrix in Python
- Python | Initialize dictionary with common value
- Python | Initialize common value to keys
- Python | Initialize dictionary with None values
- Python | Initialize tuples with parameters
- Python | Which is faster to initialize lists?
- Python | Initialize a dictionary with only keys from a list
- Python | Ways to initialize list with alphabets
- Python - Initialize dictionary with custom value list
- Python | Initialize dictionary with multiple keys
- Python - Initialize dictionary keys with Matrix
- Python | dtype object length of Numpy array of strings
- How to check whether an array is empty using PHP?
- Program to remove empty array elements in PHP
- numpy.empty() in Python
- Python Pytorch empty() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.