How to Add Element to an Empty List in Python

To add an element to an empty list in Python, you can use the append() function or the + operator.

The following examples show how to add elements to an empty list using two different methods.

Using append() Function

We can use the append() function to add an element to an empty list.

Suppose we have the following empty list:

# Declare empty list
Numbers = []

# Add elements to list
Numbers.append(2)

# Show updated list
print(Numbers)

Output: 👇️

[2]

In this example, we use the append() function to add the element 2 to the empty list Numbers.

Using + Operator

We can use the + operator to add an element to an empty list.

Suppose we have the same empty list as above.

We can use the following code to add the element “o” to the list:

# Add elements to list
Numbers = Numbers + ["o"]

# Show updated list
print(Numbers)

Output: 👇️

['o']

In this example, we use the + operator to add the element “o” to the empty list Numbers.