Python Tutoring Online
 Home            

Python List append() Method

The Python list append() method is used to add a single item to the end of a Python list. The append() method is one of the most frequently used Python list methods and is especially useful when a program needs to build or update a list dynamically.

If you are learning Python lists, understanding how append() works is essential. You will commonly use it when collecting values in a loop, storing user input, building results, processing data, creating nested lists, and constructing datasets.

Need Help Learning Python?

List methods such as append() are essential for working with dynamic data in Python programs.

If you are learning Python and need help understanding lists, loops, data structures, assignments or programming projects, one-to-one Python tutoring can help you learn faster.

Get Python Tutoring Help

What Does append() Do in Python?

The append() method in Python adds one item to the end of an existing list. The new item is placed after the last element currently in the list.

For example, if a list contains:

numbers = [10, 20, 30]

and you use:

numbers.append(40)

the list becomes:

[10, 20, 30, 40]

The important point is that append() adds one object to the list. That object can be a number, string, Boolean value, tuple, dictionary, another list, or another Python object.

Python List append() Syntax

The syntax of the Python list append() method is:

list.append(element)

Here:

For example:

numbers.append(50)

This adds 50 to the end of the numbers list.

How to Append an Item to a List in Python

The simplest way to append an item to a Python list is to call append() on the list and provide the item as its argument.

Python
numbers = [10, 20, 30]

numbers.append(40)

print(numbers)

Output

[10, 20, 30, 40]

The original list contained three elements. After calling append(40), the list contains four elements and 40 is the last item.

Example 1: Append a Number to a Python List

You can use append() to add integers or floating-point numbers to a list.

Python
numbers = [10, 20, 30]

numbers.append(40)

print(numbers)

Output

[10, 20, 30, 40]

The value 40 is appended to the end of the list.

Example 2: Append a String to a List

The append() method can also add strings to a Python list.

Python
fruits = ["apple", "banana", "cherry"]

fruits.append("orange")

print(fruits)

Output

['apple', 'banana', 'cherry', 'orange']

Here, the string "orange" becomes the fourth element in the list.

Example 3: Append a Boolean Value

Python lists can contain Boolean values such as True and False.

Python
answers = [True, False, True]

answers.append(False)

print(answers)

Output

[True, False, True, False]

Example 4: Append a Floating-Point Number

Python
prices = [10.50, 20.75, 15.25]

prices.append(30.99)

print(prices)

Output

[10.5, 20.75, 15.25, 30.99]

Example 5: Append to an Empty List

A very common use of append() is to start with an empty list and add elements to it as a program runs.

Python
numbers = []

numbers.append(10)
numbers.append(20)
numbers.append(30)

print(numbers)

Output

[10, 20, 30]

This technique is useful when the values are not known when the program starts.

Example 6: Append Items Dynamically Using a for Loop

One of the most important uses of append() is building a list dynamically inside a loop.

Python
numbers = []

for i in range(5):
    numbers.append(i)

print(numbers)

Output

[0, 1, 2, 3, 4]

The list begins empty. During each iteration of the loop, the current value of i is appended to the list.

This pattern is extremely common in Python programming:

result = []

for item in collection:
    result.append(item)

Example 7: Append Calculated Values

The append() method is often used to store the results of calculations.

Python
numbers = [1, 2, 3, 4, 5]

squares = []

for number in numbers:
    squares.append(number ** 2)

print(squares)

Output

[1, 4, 9, 16, 25]

Each square is calculated and then added to the squares list.

Example 8: Append Only Matching Values

You can combine append() with an if statement to build a list containing only values that satisfy a condition.

Python
numbers = [5, 12, 8, 20, 3, 15]

large_numbers = []

for number in numbers:
    if number >= 10:
        large_numbers.append(number)

print(large_numbers)

Output

[12, 20, 15]

Only numbers greater than or equal to 10 are appended to the new list.

Example 9: Append a List to Another List

A Python list can itself be appended to another list. When this happens, the entire list is added as one element.

Python
list1 = [1, 2, 3]

list1.append([4, 5])

print(list1)

Output

[1, 2, 3, [4, 5]]

Notice that [4, 5] remains together as a nested list. Python does not add 4 and 5 as separate elements.

This behaviour is one of the most important things to understand about append().

Example 10: Append a Tuple to a List

The object passed to append() can be a tuple.

Python
data = [1, 2, 3]

data.append((4, 5))

print(data)

Output

[1, 2, 3, (4, 5)]

The tuple is added as one element.

Example 11: Append a Dictionary to a List

A dictionary can also be appended to a list. This is particularly useful when creating a collection of records.

Python
students = []

students.append({"name": "Ali", "score": 85})
students.append({"name": "Sara", "score": 92})

print(students)

Output

[{'name': 'Ali', 'score': 85}, {'name': 'Sara', 'score': 92}]

This pattern is frequently used when working with structured data, records and simple datasets in Python.

Example 12: Append Lists of Student Records

You can use append() to build a list containing multiple student records.

Python
students = []

students.append(["Ali", 85])
students.append(["Sara", 92])
students.append(["John", 78])

print(students)

Output

[['Ali', 85], ['Sara', 92], ['John', 78]]

Each student record is appended as one element of the outer list.

Example 13: Append User Input to a List

The append() method is useful when a program collects values from a user.

Python
names = []

name1 = "Ali"
name2 = "Sara"
name3 = "John"

names.append(name1)
names.append(name2)
names.append(name3)

print(names)

Output

['Ali', 'Sara', 'John']

In a real interactive program, the values could come from input(), a form, a file, or another data source.

Example 14: Append Data While Processing a List

A common programming pattern is to process each item and append the result to a separate list.

Python
prices = [100, 200, 300, 400]

discounted = []

for price in prices:
    new_price = price * 0.90
    discounted.append(new_price)

print(discounted)

Output

[90.0, 180.0, 270.0, 360.0]

Here, append() is being used to build a new list from calculated results.

append() Does Not Create a New List

The append() method modifies the existing list. It does not normally create and return a new list.

Python
numbers = [1, 2, 3]

numbers.append(4)

print(numbers)

Output

[1, 2, 3, 4]

The original numbers list has been changed.

What Does append() Return?

A common Python beginner mistake is assuming that append() returns the updated list.

It does not. The append() method returns None.

Python
numbers = [1, 2, 3]

result = numbers.append(4)

print(result)
print(numbers)

Output

None
[1, 2, 3, 4]

The list is modified, but the return value of append() is None.

A Common append() Mistake

Do not write:

numbers = numbers.append(4)

This causes numbers to become None, because the method returns None.

Instead, simply write:

numbers.append(4)

append() vs extend()

One of the most common questions when learning Python lists is the difference between append() and extend().

Method What it does Example Result
append() Adds one object as one element list.append([4,5]) [1,2,3,[4,5]]
extend() Adds elements individually list.extend([4,5]) [1,2,3,4,5]

append() and extend() Example

Python
list1 = [1, 2, 3]

list1.append([4, 5])

print(list1)


list2 = [1, 2, 3]

list2.extend([4, 5])

print(list2)

Output

[1, 2, 3, [4, 5]]
[1, 2, 3, 4, 5]

Use append() when you want to add the object itself. Use extend() when you want to add the elements contained inside an iterable.

append() vs insert()

Both append() and insert() add an item to a list, but they are used differently.

Method Purpose
append() Adds an item to the end of the list
insert() Adds an item at a specified position
Python
numbers1 = [1, 2, 3]
numbers1.append(4)

numbers2 = [1, 2, 3]
numbers2.insert(1, 4)

print(numbers1)
print(numbers2)

Output

[1, 2, 3, 4]
[1, 4, 2, 3]

append() vs + Operator

The + operator can also be used to combine lists, but it works differently from append().

Python
numbers = [1, 2, 3]

new_numbers = numbers + [4]

print(numbers)
print(new_numbers)

Output

[1, 2, 3]
[1, 2, 3, 4]

The + operator creates a new list, whereas append() modifies the existing list.

Appending Multiple Items

The append() method accepts only one argument. Therefore, the following is not valid:

numbers.append(4, 5)

If you want to add multiple individual elements, use extend():

numbers.extend([4, 5])

Alternatively, you can call append() multiple times:

numbers.append(4)
numbers.append(5)

Can append() Add Different Data Types?

Yes. Python lists can contain objects of different data types, and append() can add any appropriate Python object.

Python
items = [10, "Python", 3.14, True]

items.append([1, 2, 3])

print(items)

Output

[10, 'Python', 3.14, True, [1, 2, 3]]

Python lists are flexible, although in real applications it is often better to keep collections logically consistent where possible.

Appending Objects in a Loop

The append() method is particularly important in loops because it allows a program to accumulate results one item at a time.

Python
results = []

for number in range(1, 6):
    result = number * 10
    results.append(result)

print(results)

Output

[10, 20, 30, 40, 50]

This is one of the fundamental patterns used in Python programming, data processing and algorithm development.

Using append() with Conditional Logic

You can use append() together with conditional statements to collect only values that meet specific criteria.

Python
marks = [45, 72, 88, 39, 91, 65]

passed = []

for mark in marks:
    if mark >= 50:
        passed.append(mark)

print(passed)

Output

[72, 88, 91, 65]

This approach is useful for filtering data and building result lists.

Real-World Uses of Python append()

The append() method is not only useful in simple examples. It is frequently used in real Python programs whenever data needs to be collected or accumulated.

1. Building a List of Results

A program can process values and append each calculated result to a new list.

2. Collecting Data

Programs can append records obtained from files, APIs, databases, forms or other data sources.

3. Processing Student Marks

Educational programs can append marks, grades or student records to lists while processing student data.

4. Data Analysis

Python programs can use append() to collect calculated statistics, filtered observations or transformed data before further analysis.

5. Building Dataset Records

A list can be built row by row before being converted into a DataFrame or processed by another Python library.

6. Collecting Search Results

A program can append matching records to a result list while searching through a collection.

Example: Building Dataset Rows with append()

The following example demonstrates how append() can be used to build a simple dataset.

Python
data = []

data.append(["Ali", 21, 85])
data.append(["Sara", 22, 92])
data.append(["John", 20, 78])

print(data)

Output

[['Ali', 21, 85], ['Sara', 22, 92], ['John', 20, 78]]

Each row is appended as one list inside the outer list.

Example: Append Calculated Business Results

Suppose a business wants to calculate revenue from units sold and price. The calculated values can be collected using append().

Python
units = [10, 20, 15, 30]
price = 100

revenue = []

for quantity in units:
    revenue.append(quantity * price)

print(revenue)

Output

[1000, 2000, 1500, 3000]

This demonstrates why append() is important in data processing: the program can calculate and collect results dynamically.

Example: Append Only Even Numbers

Python
numbers = range(1, 11)

even_numbers = []

for number in numbers:
    if number % 2 == 0:
        even_numbers.append(number)

print(even_numbers)

Output

[2, 4, 6, 8, 10]

Here, append() is used to build a list containing only numbers that satisfy the condition.

append() with List Comprehension

List comprehensions can sometimes replace the loop-and-append pattern. For example:

Python
numbers = [1, 2, 3, 4, 5]

squares = [number ** 2 for number in numbers]

print(squares)

Output

[1, 4, 9, 16, 25]

However, understanding append() first is important because the loop-and-append pattern makes the underlying process easier to understand.

Time Complexity of append()

Appending an item to the end of a Python list is generally an O(1) amortized operation. This means that adding an item is normally very efficient.

Python lists are dynamic arrays. Occasionally, the list may need to allocate additional storage when its internal capacity is reached. Although such resizing can take longer for an individual operation, the average cost of repeated appends remains efficient.

For most everyday Python programs, append() is the standard and efficient way to add an item to the end of a list.

Important Characteristics of append()

Characteristic Description
Purpose Adds one item to the end of a list
Arguments One argument
Changes original list Yes
Return value None
Can append another list? Yes, as one nested element
Can append a string? Yes, as one string element
Typical complexity O(1) amortized

Common Beginner Mistakes with append()

Mistake 1: Expecting append() to Return the List

This is incorrect:

numbers = numbers.append(40)

Because append() returns None, this assignment will replace the variable with None.

Use:

numbers.append(40)

Mistake 2: Trying to Append Multiple Arguments

This is incorrect:

numbers.append(40, 50)

The method accepts one argument. Use:

numbers.extend([40, 50])

or:

numbers.append(40)
numbers.append(50)

Mistake 3: Confusing append() and extend()

Remember:

numbers.append([4, 5])

produces:

[1, 2, 3, [4, 5]]

whereas:

numbers.extend([4, 5])

produces:

[1, 2, 3, 4, 5]

Mistake 4: Forgetting That append() Changes the Original List

The method modifies the list in place. If another variable refers to the same list, that reference will also see the modification.

Python
numbers = [1, 2, 3]

other = numbers

numbers.append(4)

print(other)

Output

[1, 2, 3, 4]

When Should You Use append()?

Use append() when you need to add one item to the end of a list.

Typical situations include:

When Should You Use extend() Instead?

Use extend() when you have an iterable containing multiple elements and you want those elements added individually to the list.

For example:

numbers = [1, 2, 3]

numbers.extend([4, 5, 6])

print(numbers)

Result:

[1, 2, 3, 4, 5, 6]

Python append() Method: Key Points to Remember

Frequently Asked Questions About Python append()

What is append() in Python?

append() is a Python list method used to add one item to the end of an existing list.

How do I append an item to a list in Python?

Call append() on the list and provide the item you want to add. For example:

numbers = [1, 2, 3]
numbers.append(4)

What does append() do to a list?

It adds one new element at the end of the list and modifies the original list.

Does Python append() add to the beginning or end?

The append() method adds the new element to the end of the list.

Can append() add multiple items?

No. The append() method accepts one argument. To add multiple elements individually, use extend() or call append() multiple times.

What is the difference between append() and extend() in Python?

append() adds its argument as one element, while extend() adds the elements of an iterable individually.

Can I append a list to another list in Python?

Yes. When you use append() with another list, the entire list is added as one element.

numbers = [1, 2, 3]
numbers.append([4, 5])

print(numbers)

The result is:

[1, 2, 3, [4, 5]]

What does append() return in Python?

The append() method returns None. It modifies the original list rather than returning a new list.

Does append() change the original list?

Yes. append() modifies the existing list in place.

Can append() add a string to a Python list?

Yes. A string passed to append() is added as one element. For example:

names = ["Ali", "Sara"]

names.append("John")

Can append() be used in a for loop?

Yes. Using append() inside a for loop is one of the most common ways to build a Python list dynamically.

How do I append a value only if a condition is true?

You can use an if statement before calling append().

numbers = []

for number in range(1, 6):
    if number % 2 == 0:
        numbers.append(number)

print(numbers)

This produces:

[2, 4]

Is append() the same as insert()?

No. append() always adds an item to the end of the list, while insert() allows you to specify the position.

Is append() the same as concatenation?

No. List concatenation using + creates a new list, while append() modifies the existing list.

Why does my list become None after using append()?

This usually happens when the return value of append() is assigned back to the list. Since append() returns None, code such as numbers = numbers.append(4) replaces the list with None.

Related Python List Tutorials

Learn Python Lists with Practical Examples

Understanding append() is an important step toward becoming comfortable with Python lists. Once you understand how to add elements, you can move on to inserting, removing, sorting, searching and processing list data.

Explore the complete Python Lists tutorial for more examples and practice with Python list methods.

Learn Python Lists




Stuck Learning Python?

Struggling with Python syntax, assignments or debugging errors? Learning alone can be frustrating.

Get 1-on-1 Python tutoring and learn faster with clear explanations, real examples and live help.

    Get Python Tutoring

PythonTutor.net

Home    Tutorial     Online Live Trainings    Contact Us           © 2026 All rights reserved by www.PythonTutor.net