The basic way to add one item to a list

The most common way to add a single item to a Python list is the append() method. You write the list name, then a dot, then append() with the item you want to add inside the parentheses.

Here is what that looks like in practice. If you have a list called fruits that contains apples and bananas, and you want to add oranges, you write: fruits.append("oranges"). After you run that line, oranges will be at the end of the list.

The append() method changes the list itself — it does not create a new list or return a value you need to save. This is the method you will use most often when you are building a list as your program runs.

Key Takeaways

  • Use append() to add a single item to the end of an existing list, and the change happens to the list itself.
  • Use extend() when you want to add multiple items at once, such as adding all the items from one list to another.
  • Use insert() if you need to add an item at a specific position in the list rather than at the end.
  • The plus operator (+) creates a new list by combining two lists, but does not change the original lists.

Adding multiple items at once with extend()

When you have several items to add and you want to add them all in one step, use extend() instead of append(). The extend() method takes a list of items and adds each one to the end of your original list.

For example, if you have a list called colors with red and blue, and you want to add green, yellow, and purple all at once, you write: colors.extend(["green", "yellow", "purple"]). After this runs, your colors list will have five items in this order: red, blue, green, yellow, purple.

A common mistake is using append() when you mean extend(). If you write colors.append(["green", "yellow", "purple"]), Python will add the entire list as a single item, so your colors list will have three items: red, blue, and a list inside it. That is usually not what you want.

Adding an item at a specific position with insert()

Sometimes you need to add an item somewhere in the middle of a list, not at the end. Use the insert() method for this. You give insert() two pieces of information: the position where you want the item to go, and the item itself.

Positions in Python lists start at 0, not 1. The first item is at position 0, the second item is at position 1, and so on. If you have a list called numbers with 1, 2, and 4, and you want to insert 3 between 2 and 4, you write: numbers.insert(2, 3). The 3 goes into position 2, which pushes 4 to position 3.

If you give insert() a position that is beyond the end of the list, Python will just add the item at the end. If you give it a negative number, Python counts backward from the end of the list, so position -1 means the last item.

Combining two lists with the plus operator

You can also add items to a list by combining two lists with the plus sign (+). When you write list1 + list2, Python creates a brand new list that contains all the items from list1 followed by all the items from list2.

This is different from extend() because it does not change either of your original lists. If you have colors = ["red", "blue"] and more_colors = ["green", "yellow"], and you write combined = colors + more_colors, then combined will be a new list with all four colors, but colors and more_colors stay the same.

If you want to keep the result, you need to save it to a variable. If you write colors = colors + more_colors, you are replacing the colors list with a new combined list. This works, but extend() is faster if you just want to add items to an existing list.

Adding items from user input or a loop

In real programs, you often add items to a list as they come in — from user input, from reading a file, or from a loop that processes data. The pattern is always the same: create an empty list first, then use append() inside your loop or input section to add each item as it arrives.

Here is a common example: you want to collect numbers from a user until they type "done". You create an empty list called numbers = [], then use a loop that asks for input, checks if it is "done", and if not, adds it to the list with numbers.append(). When the user types "done", the loop stops and you have a list of all the numbers they entered.

This pattern works the same way whether you are reading from a file, processing data from a database, or getting items from any other source. Start with an empty list and append() each item as you encounter it.

What happens when you add the wrong type of item

Python lists can hold any type of item — numbers, text, other lists, or even a mix of different types. When you add an item with append(), extend(), or insert(), Python does not check whether the item matches what is already in the list.

This means you can accidentally add a number to a list of text, or text to a list of numbers, and Python will not stop you. Your program will still run, but later code that expects all items to be the same type might break. If you are building a list that should only hold one type of item, check your data before you add it, or add a comment in your code explaining why the list might hold mixed types.

Frequently Asked Questions

What is the difference between append and extend?

append() adds a single item to the end of the list, while extend() adds multiple items. If you use append() with a list as the item, the entire list becomes one item inside your original list. extend() unpacks the items and adds each one separately.

Can I add an item to the beginning of a list?

Yes, use insert(0, item) to add an item at position 0, which is the beginning. All other items shift one position forward. This works, but if you are adding to the beginning often, a different data structure called a deque might be faster.

Does append change the original list or create a new one?

append() changes the original list itself. It does not create a new list or return a value. If you want to keep the original list unchanged, use the plus operator to create a new combined list instead.

What if I try to add an item to a list that does not exist yet?

You will get an error. Always create the list first with my_list = [] before you try to append to it. Once the list exists, even if it is empty, you can add items to it.

Can I add the same item multiple times?

Yes, Python will add it each time you call append(). If you append the number 5 three times, your list will have three separate 5s in it. Python does not remove duplicates automatically.