You can create an empty list using the None Multiplication or Using the range() function in Python.
The multiplication method is best if you want to initialize a list with the same values. A range() a statement is a good choice if you want a list to contain values in a particular range.
list1 = [None] * size
List1 = [None for x in range(size)] List2 = [ for x in range(size)]
Creating an empty list in Python example
Simple Python example codes:
Initialize List of Size N Using Multiplication
lst = [None] * 5 print(lst)
Initialize List of Size N Using range()
lst = [ for i in range(5)] print(lst)
Output: [[ ], [ ], [ ], [ ], [ ]]
Do comment if you have any doubts and suggestions on this Python list topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.