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]]
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.