Create Empty List in Python (2 Examples)

 

In this Python programming tutorial you’ll learn how to create empty lists in Python.

The post will contain the following content:

Let’s get started!

 

Example 1: Create Empty Lists using Square Brackets

In the first example, we will utilize square brackets to create an empty list. The square bracket notation in Python is the standard way to denote lists.

When the user does not include any elements in square brackets, an empty list will be created.

empty_list = []              # create empty list
 
print(empty_list)            # print empty list
# []

As seen, the empty list is successfully created. Now let’s see another alternative!

 

Example 2: Create Empty Lists using List Constructor

The list() function in Python serves as a constructor for the list data type. When invoked without any arguments, it returns an empty list.

empty_list_2 = list()        # create empty list
 
print(empty_list_2)          # print empty list
# []

You can see above, how an empty list can be created using list().

Additionally, it is worth noting that this constructor can convert other iterable types (like tuples or strings) into lists.

 

Video, Further Resources & Summary

Do you need further info on the contents of the present article? Then you may want to have a look at the following video tutorial on my YouTube channel. I’m explaining the examples of this article in the video:

 

The YouTube video will be added soon.

 

Also, you could read the related articles that I have published on my website. You can find a selection of tutorials on topics such as character strings and lists below:

 

In this tutorial you have learned how to build empty lists in Python programming. In case you have further questions or comments, don’t hesitate to let me know in the comments.

 

Cansu Kebabci R Programmer & Data Scientist

This page was created in collaboration with Cansu Kebabci. Have a look at Cansu’s author page to get more information about her professional background, a list of all his tutorials, as well as an overview on her other tasks on Statistics Globe.

 

Subscribe to the Statistics Globe Newsletter

Get regular updates on the latest tutorials, offers & news at Statistics Globe.
I hate spam & you may opt out anytime: Privacy Policy.


Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Top