Python List Methods

In the last lesson you learned List Operations. There you joined lists, repeated them, and checked if an item was inside. That covered the operators. Now let’s look at the built-in tools that come attached to every list. These are the list methods. They let you add items, remove items, and rearrange a list without writing the logic yourself.

🤔 Why list methods?

Say you have a list of names and a new person signs up. How do you add them? You could try to rebuild the whole list by hand. That is slow and easy to get wrong.

A list method does the job for you in one line. You just say “add this”, “remove that”, or “find where this is”. Python handles the rest. So instead of writing loops to manage your list, you call the right method and move on.

🧩 What a method is

A method is a function that belongs to an object. You call it by writing the list name, a dot, then the method name with round brackets. Like this: my_list.append("Alex").

Think of it like a phone. The phone is the object. “Call”, “text”, and “take a photo” are the methods. They are things the phone can do. A list works the same way. The list is the object. append, remove, and pop are things the list can do.

One important idea before we start. Most list methods change the list in place. That means they edit the same list directly. They do not hand you back a new list. So you do not write my_list = my_list.append(...). You just write my_list.append(...) and the original list is updated.

We will use one running list through this whole lesson so you can watch it grow and shrink.

➕ append() — add one item to the end

append() takes one value and sticks it on the end of the list. This is the method you will reach for most often.

Here we start with three fruits and add one more to the end.

fruits = ["apple", "banana", "cherry"]
fruits.append("mango")
print(fruits)

Output

['apple', 'banana', 'cherry', 'mango']

See how "mango" landed at the very end? append always adds to the back. And it always adds exactly one item. If you pass it a list, that whole list becomes a single item inside.

fruits = ["apple", "banana"]
fruits.append(["cherry", "mango"])
print(fruits)

Output

['apple', 'banana', ['cherry', 'mango']]

That nested list is probably not what you wanted. When you have many items to add, you want extend() instead. We will meet it soon.

📍 insert() — add at a specific position

append only adds to the end. But what if you want the new item somewhere in the middle? That is where insert() comes in. You give it two things. First the position (the index) where the item should go. Then the value.

Here we drop "banana" into position 1, so it sits between "apple" and "cherry".

fruits = ["apple", "cherry", "mango"]
fruits.insert(1, "banana")
print(fruits)

Output

['apple', 'banana', 'cherry', 'mango']

Remember that index 0 is the first slot, 1 is the second, and so on. So insert(1, "banana") means “put banana in the second slot and push everything else to the right”. If you pick an index bigger than the list, Python just adds the item to the end. No error.

➕➕ extend() — add many items at once

extend() is the fix for that nested-list problem from earlier. It takes a list (or any group of items) and adds each one separately to the end.

Here we have two fruits and we add three more in one go.

fruits = ["apple", "banana"]
fruits.extend(["cherry", "mango", "kiwi"])
print(fruits)

Output

['apple', 'banana', 'cherry', 'mango', 'kiwi']

See the difference? append(["cherry", "mango"]) would have buried one list inside another. extend(["cherry", "mango"]) pulls the items out and lays them flat. So the rule is simple. One item, use append. Many items, use extend.

❌ remove() — delete by value

Now let’s start taking things out. remove() deletes an item by its value. You tell it what to delete, not where it is. You do not need to know the position.

Here we remove "banana" from the list.

fruits = ["apple", "banana", "cherry", "mango"]
fruits.remove("banana")
print(fruits)

Output

['apple', 'cherry', 'mango']

Two things to watch for. If the same value appears more than once, remove only deletes the first one it finds. And if the value is not in the list at all, Python raises an error and stops. So check it is there first, or be ready to handle the error.

fruits = ["apple", "cherry"]
fruits.remove("banana")

Output

Traceback (most recent call last):
File "main.py", line 2, in <module>
fruits.remove("banana")
ValueError: list.remove(x): x not in list

⬆️ pop() — remove by index and get it back

pop() is different from remove in two ways. It deletes by position, not by value. And it hands the removed item back to you so you can use it.

Here we pop the item at index 1 and store it in a variable.

fruits = ["apple", "banana", "cherry", "mango"]
removed = fruits.pop(1)
print(removed)
print(fruits)

Output

banana
['apple', 'cherry', 'mango']

Notice removed now holds "banana". That return value is the whole point of pop. It is handy when you want to take an item out and do something with it.

If you call pop() with no index, it removes and returns the last item. This is how people often use a list as a stack, taking items off the top.

fruits = ["apple", "banana", "cherry"]
last = fruits.pop()
print(last)
print(fruits)

Output

cherry
['apple', 'banana']

Tip

Use remove when you know the value but not the position. Use pop when you know the position and want the item back.

🔎 index() — find where an item is

Sometimes you do not want to delete anything. You just want to know where an item sits. index() searches the list and gives you the position of the first match.

Here we ask where "cherry" is.

fruits = ["apple", "banana", "cherry", "mango"]
position = fruits.index("cherry")
print(position)

Output

2

So "cherry" is at index 2, the third slot. Just like remove, if the value is not in the list, index raises an error. So if you are not sure the item is there, check with in first, like if "cherry" in fruits:.

🔢 count() — how many times an item appears

count() tells you how many times a value shows up in the list. This one does not change the list at all. It just counts and returns a number.

Here we count how many times "apple" appears.

fruits = ["apple", "banana", "apple", "cherry", "apple"]
total = fruits.count("apple")
print(total)

Output

3

If the value is not in the list, count does not raise an error. It simply returns 0. So count is also a safe way to check if something exists. A count of zero means it is not there.

🔄 reverse() — flip the order

reverse() turns the list back to front. The last item becomes first and the first becomes last. It changes the list in place and returns nothing.

Here we flip the order of the fruits.

fruits = ["apple", "banana", "cherry", "mango"]
fruits.reverse()
print(fruits)

Output

['mango', 'cherry', 'banana', 'apple']

Note that reverse only flips the order. It does not sort. If you want the items in alphabetical or numerical order, that is a different method called sort. You will meet it in its own lesson.

🧹 clear() — empty the whole list

clear() removes every item and leaves you with an empty list. The variable still exists. It just has nothing inside now.

Here we empty the list completely.

fruits = ["apple", "banana", "cherry"]
fruits.clear()
print(fruits)

Output

[]

This is cleaner than trying to delete items one by one. When you want a fresh start but want to keep using the same list variable, clear is the tool.

📋 Quick reference

Here is every method from this lesson in one place. The “Changes the list?” column tells you whether the method edits the list in place or just reads from it.

Method What it does Changes the list? Returns
append(x) Add one item to the end Yes Nothing
insert(i, x) Add an item at position i Yes Nothing
extend(items) Add many items to the end Yes Nothing
remove(x) Delete the first matching value Yes Nothing
pop(i) Delete by index and return it Yes The removed item
index(x) Find the position of a value No The index number
count(x) Count how many times a value appears No A number
reverse() Flip the order back to front Yes Nothing
clear() Remove every item Yes Nothing

⚠️ Common Mistakes

A few traps catch people again and again. Watch out for these.

  • Saving the result of an in-place method. Methods like append and reverse return None, not the list. If you assign the result back, you lose your list.
# ❌ Avoid: this sets fruits to None
fruits = fruits.append("kiwi")
# ✅ Good: just call it, the list updates itself
fruits.append("kiwi")
  • Calling remove or index on a value that is not there. Both raise a ValueError and stop your program. Check first with in.
# ❌ Avoid: crashes if "kiwi" is missing
fruits.remove("kiwi")
# ✅ Good: check before you delete
if "kiwi" in fruits:
fruits.remove("kiwi")
  • Mixing up append and extend. append adds the whole thing as one item. extend adds each item separately. One item, append. Many items, extend.

  • Confusing remove and pop. remove takes a value, pop takes an index. If you pass a value to pop, Python treats it as a position and you get the wrong item or an error.

✅ Best Practices

  • Pick the method that says what you mean. append for one, extend for many, pop when you need the item back, remove when you only know the value.
  • Remember that most of these change the list in place. Do not assign their result to a variable.
  • Before remove or index, make sure the value is in the list. Or use count to check safely, since it returns 0 instead of crashing.
  • Reach for clear() to empty a list instead of writing a loop to delete items.

🧩 What You’ve Learned

  • append() adds one item to the end, and insert() adds one item at a chosen position.
  • extend() adds many items at once, laying them out flat instead of nesting them.
  • remove() deletes by value, while pop() deletes by index and hands the item back.
  • index() finds where a value sits, and count() tells you how many times it appears.
  • reverse() flips the order, and clear() empties the whole list.
  • ✅ Most list methods change the list in place and return None, so you call them directly without reassigning.

Check Your Knowledge

Test what you learned. Pick an answer for each question, then click Check.

  1. 1

    What does fruits.append(['a', 'b']) do to the list?

    Why: append adds whatever you pass as a single item, so a list goes in as one nested element. Use extend to add items separately.

  2. 2

    Which method deletes an item by its index and returns that item to you?

    Why: pop() removes the item at a given index and returns it, while remove() deletes by value and returns nothing.

  3. 3

    What does fruits.count('kiwi') return when 'kiwi' is not in the list?

    Why: count() never raises an error for a missing value; it simply returns 0, which makes it a safe way to check existence.

  4. 4

    What is the result of writing fruits = fruits.reverse()?

    Why: reverse() changes the list in place and returns None, so assigning its result sets fruits to None and loses the list.

🚀 What’s Next?

You can now add, remove, find, and rearrange items in a list. Next you will learn how to grab a whole section of a list at once. That opens up a lot of clean, short code.

List Slicing

Share & Connect