Python – Create an Empty List
Python list is a data structure that can store multiple elements of heterogeneous type. At some point in your program, you may need to create an empty list and add items to it in the subsequent steps.
In this tutorial, we shall learn how to create an empty list. In other words, a List with no elements.
To create an empty list in python, assign the variable with empty square brackets.
mylist = 
 is an empty list.
You can also use list class constructor as shown below to create an empty list.
mylist = list()
Example 1: Create an Empty List
In the following example, we will create an empty list and check the datatype of the variable.
cars =  print(type(cars))
If you check the length of this Python list, you would get zero as length.
Example 2: Create an Empty List
In the following example, we will create an empty list using list class constructor.
cars = list() print(type(cars))
In this tutorial of Python Examples, we learned some of the ways to create an empty list, with the help of well detailed example programs.
- How to Insert Item at Specific Index in Python List?
- Shuffle Python List
- Python Program to Find Largest Number in a List
- Python Program to Find Duplicate Items of a List
- Python – Convert List to Dictionary
- How to Append List to Another List in Python? – list.extend(list)
- Python – Count the items with a specific value in the List
- Python List without Last Element
- How to Sort Python List?
- Python List of Lists