How to create an empty list in Python

Sharing buttons:

in this video we're going to see how we

can create an empty list using Python

there's two different strategies that we

might use to do this one of these is

using the list constructor directly with

an open any close parenthesis the other

is to use the list literal syntax of an

open and a closed square brace if you're

someone who's been working in Python for

a while now the second form is going to

feel more idiomatic and is going to be

easy to read and to understand there is

also a performance difference between

these two methods to see how this looks

we can time how long it takes to create

an empty list first using the list

constructor and then again using the

literal syntax and what we'll see here

is that using this literal syntax gives

us about a five times speed-up over the

other method I mean should be preferred

when you can use it because in Python

programs we very frequently create a lot

of empty lists