How to Create an Empty List in Python
To create an empty list in Python, you can use [] square brackets or the list() function.
The following examples show how to create an empty list in Python using two different methods.
Using [] Square Bracket
We can use [] square brackets to create an empty list.
Let’s see how to use [] square brackets in Python:
# Create empty list
list_ = []
# Show empty list
print(list_)
Output: 👇️
[]
The output shows the empty list created using [] square brackets.
Using list() Function
We can use the list() function to create an empty list.
Let’s see how to use the list() function in Python:
# Create empty list
list_ = list()
# Show empty list
print(list_)
Output: 👇️
[]
The output shows the empty list created using the list() function.
Conclusion
We can use [] square brackets or the list() function to create an empty list in Python.