Member-only story

How to Create an Empty List in Python? | Python Examples Series

Developers Group
1 min readOct 4, 2021

In this tutorial, we will learn how to create an empty list. In other words, a List with no elements But before that What’s A Python List Exactly?

In short, a list is a collection of arbitrary objects, somewhat akin to an array in many other programming languages but more flexible. Lists are defined in Python by enclosing a comma-separated sequence of objects in square brackets ([])

To create an empty list in python, assign the variable with empty square brackets.
mylist = []

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.
books = []
print(type(books))

Output: <class 'list'>

Example 2: Create an Empty List

In the following example, we will create an empty list using list class constructor.
books = list()
print(type(books))

Output: <class 'list'>

Related Article: Dictionaries in Python? | Straightforward Python

Related Article: What’s A Python List Exactly? | Straightforward Python

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Developers Group
Developers Group

Written by Developers Group

A Developer is responsible for coding, designing, deploying, and debugging development projects, typically on the server-side (or back-end).

No responses yet

Write a response