in this tutorial we'll learn how to define an empty list in python

syntax

1
2
#syntax
lst_var = []

example 1

1
2
3
4
5
#example
list_1 = []

#print type
print(type(list_1))

output

1
<class 'list'>

Example 2 Using list() constructor

syntax


var = liist()    




#define an empty list using list()

# declare empty list
list_1 = list()   
  
print("Type of a:", type(list_1)) 
print("Size of a:", len(list_1))   

output

Type of a: class 'list'
Size of a: 0

as you can see the size of the list is zero that mean the list is empty

English today is not an art to be mastered it's just a tool to use to get a result