How to Append Element to List in Python

To append an element to a list in Python, you can use the append() function.

Method: Use append() Function

my_list.append(n)

The following example shows how to append an element to a list in Python using the append() function.

Using append() Function

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

Suppose we have the following list:

# Declare list
my_list = [1, 2, 3]

# Add element to list
my_list.append(4)

# Show updated list
print("Updated list:", my_list)

Output: 👇️

Updated list: [1, 2, 3, 4]

In this example, we use the append() function to add the element 4 to the list my_list.