DEV Community

Shivani tiwari
Shivani tiwari

Posted on

How to Create an Empty List in python

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.

[] is an empty list.

mylist = []

You can also use list class constructor as shown below to create an empty list.

mylist = list()

Example 1: Create an Empty List

fruits = []
print(type(fruits))
Enter fullscreen mode Exit fullscreen mode

Example 2: Create an Empty List

fruits = list()
print(type(fruits))
Enter fullscreen mode Exit fullscreen mode

Read more articles click here -https://codersvillage.com/

I hope you guys understand how to create empty list if like so support me and follow me for more updates

Thank you
Everyone

Top comments (0)