In this Python tutorial, you will learn how to create an empty list using list() built-in function or square bracket notation.
Python – Create an Empty List
To create an empty List in Python, we can use list() built-in function with no argument passed to it or take empty square brackets and assign it to a variable.
The syntax to crate an empty Python List using list() function is
myList = list()
The syntax to create an empty Python List using square brackets is
myList = []
Examples (2)
1. Create empty list using list() function
In this example, we will create an empty list using list() builtin function. We shall print the type of the object returned by list() and print the object itself.
Python Program
myList = list()
print(type(myList))
print(myList)
Output
<class 'list'>
[]
2. Create empty list using square brackets
In this example, we will create an empty list with empty square brackets.
Python Program
myList = []
print(type(myList))
print(myList)
Output
<class 'list'>
[]
Conclusion
In this Python Tutorial, we learned how to create an empty Python List with the help of example programs.