The simplest way to add one item to a list
To add a single item to a list in Python, use the append() method. This adds the item to the end of the list.
Here is the actual syntax:
my_list.append(item)
For example, if you have a list of fruit names and want to add "banana" to it, you would write:
fruits = ["apple", "orange"] fruits.append("banana") print(fruits)
The output would be: ["apple", "orange", "banana"]
The append() method modifies the original list directly. It does not create a new list — it changes the one you already have.
Key Takeaways
- Use append() to add a single item to the end of an existing list.
- Use extend() when you want to add multiple items from another list all at once.
- Use insert() if you need to add an item at a specific position rather than at the end.
- The += operator works on lists and is a shorthand for extend() when you add another list to an existing one.
Adding multiple items at once with extend()
When you have several items to add and they are already grouped in another list, use extend() instead of append(). The extend() method adds each item from the new list individually, rather than adding the entire list as a single item.
The syntax is:
my_list.extend(another_list)
For example:
fruits = ["apple", "orange"] new_fruits = ["banana", "grape", "mango"] fruits.extend(new_fruits) print(fruits)
The output is: ["apple", "orange", "banana", "grape", "mango"]
If you had used append() instead, the entire new_fruits list would have been added as a single nested item, which is usually not what you want. Understanding the difference between append() and extend() prevents a common mistake when working with lists.
Inserting an item at a specific position
Sometimes you need to add an item somewhere in the middle of a list, not at the end. Use the insert() method for this. It takes two pieces of information: the position where you want the item to go, and the item itself.
The syntax is:
my_list.insert(position, item)
Positions in Python start at 0, so position 0 is the first spot, position 1 is the second, and so on. For example:
fruits = ["apple", "orange", "mango"] fruits.insert(1, "banana") print(fruits)
The output is: ["apple", "banana", "orange", "mango"]
The item "banana" was inserted at position 1, which pushed "orange" and "mango" one position forward. If you use a position number that is larger than the list length, Python straightforward adds the item at the end instead of throwing an error.
Using the += operator to combine lists
You can also add items to a list using the += operator. When you use += with two lists, it works the same way as extend() — it adds each item from the second list individually.
For example:
fruits = ["apple", "orange"] fruits += ["banana", "grape"] print(fruits)
The output is: ["apple", "orange", "banana", "grape"]
This is a shorthand that some programmers prefer because it reads more naturally. However, append() and extend() are more explicit about what you are doing, so they are often clearer to read when someone else is looking at your code.
Adding items inside loops
A common real-world use of list addition is building a list by adding items one at a time inside a loop. For example, you might want to create a list of numbers that meet a certain condition.
Here is an example that creates a list of all even numbers between 1 and 10:
even_numbers = [] for number in range(1, 11): if number % 2 == 0: even_numbers.append(number) print(even_numbers)
The output is: [2, 4, 6, 8, 10]
This pattern — starting with an empty list and appending items as you process data — is one of the most common ways lists grow in real programs. The loop runs through each number, checks if it is even, and if it is, adds it to the list.
What happens when you add different data types
Lists in Python can hold any type of data: numbers, text, other lists, or even a mix of all three. When you add an item, Python does not care what type it is.
For example:
mixed_list = [1, "hello", 3.14] mixed_list.append(True) mixed_list.append([5, 6]) print(mixed_list)
The output is: [1, "hello", 3.14, True, [5, 6]]
Notice that the list [5, 6] was added as a single nested item because we used append(). If we had used extend() instead, the numbers 5 and 6 would have been added as separate items at the top level of the list.
Frequently Asked Questions
Does append() return the new list?
No. The append() method modifies the list in place and returns None. If you write new_list = my_list.append(item), new_list will be None, not your updated list. Always use the original list variable after calling append().
What is the difference between append() and extend()?
append() adds the entire object as a single item, while extend() unpacks a list and adds each item separately. Use append() for single items and extend() when you have another list whose items you want to merge in.
Can I add an item to a list at the beginning?
Yes, use insert(0, item) to add an item at position 0, which is the start of the list. This shifts all existing items one position forward.
What happens if I insert at a position beyond the list length?
Python will not throw an error. It straightforward adds the item at the end of the list instead. For example, if your list has 3 items and you insert at position 100, the item goes to the end.
Can I add items to a list while looping through it?
You can, but it often causes unexpected behavior because the loop may process items you just added. It is safer to build a separate new list and then combine them afterward, or to loop through a copy of the original list.