What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Python lists have 11 built-in methods for adding, removing, finding, reordering, and copying items. The crucial choices are whether you’re working with one value or an iterable, removing by value or position, and changing a list in place or creating a new one.

Python list methods at a glance

The method behavior below follows the Python 3.14.7 tutorial. Most methods change the existing list and return None; the main exception for removal is pop(), which returns the removed item. Python documentation: Data Structures

Method Use Result or failure behavior
append(x) Add one item to the end Changes the list; returns None
extend(iterable) Add each item from an iterable to the end Changes the list; returns None
insert(i, x) Insert an item before index i Changes the list; returns None
remove(x) Remove the first item equal to x Changes the list; raises ValueError if no match exists
pop([i]) Remove and retrieve the item at index i; defaults to the last item Returns the removed item; raises IndexError for an empty list or invalid index
clear() Remove all items Changes the list; returns None
index(x[, start[, stop]]) Find the first matching item, optionally searching a range Returns its index in the whole list; raises ValueError if absent
count(x) Count items equal to x Returns an integer
sort(key=None, reverse=False) Sort the list in place Changes the list; returns None
reverse() Reverse the current order Changes the list; returns None
copy() Create a shallow copy Returns a new outer list; nested objects are shared

How do you add items to a list?

Use append() for one item

append(x) adds its argument as a single element at the end. If the argument is itself a list, that list becomes one nested element:

items = ["pen", "book"]
items.append(["tape", "glue"])
# ["pen", "book", ["tape", "glue"]]

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use extend() for items from an iterable

extend(iterable) adds the iterable’s elements individually. For example, items.extend(["tape", "glue"]) adds two strings to the end rather than adding a nested list. This distinction matters whenever the argument is a collection. Python documentation: Data Structures

Use insert() for a position

insert(i, x) places x before index i. For example, items.insert(1, "notebook") puts the new item before the element currently at index 1. Use append() when the destination is simply the end.

How do you remove an item?

Remove by value with remove()

remove(x) deletes the first item equal to x. If the list contains duplicates, later matching items remain. If there is no equal item, Python raises ValueError.

Remove by position and keep the value with pop()

pop(i) removes and returns the item at index i. With no argument, pop() removes and returns the last item. It raises IndexError if the list is empty or the requested index is invalid.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Empty the list with clear()

clear() removes all items from the existing list. It is different from assigning a new empty list when other variables refer to the same list: clearing changes the shared object.

How do you find or count list values?

Find a position with index()

index(x) returns the index of the first item equal to x. You can supply start and stop to limit the search: index(x, start, stop). The returned position is still measured from the beginning of the whole list, not from the start of the search range. If no match is found, Python raises ValueError.

Count matches with count()

count(x) returns the number of items equal to x, including zero when there are no matches.

How do you reorder a list?

Sort the existing list with sort()

sort() changes the list in place. It accepts an optional key function for determining sort order and reverse=True for descending order. For example, names.sort(key=str.lower) sorts strings using their lowercase forms as the keys. The elements must be orderable under the comparison or key being used.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not assign the result of sort() to a variable expecting a sorted list: it returns None. The Python tutorial explains that methods such as sort() that only modify a list have no return value printed because “they return the default None.” Python documentation: Data Structures

Keep the original order with sorted()

Use the built-in sorted(a) when you need a new sorted list and want to preserve a. Like sort(), sorted() can use key and reverse arguments.

Reverse the current order with reverse()

reverse() reverses the items’ current order in place; it does not sort them. Like other in-place list methods, it returns None.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Does list.copy() make a deep copy?

No. copy() creates a new outer list, but it is a shallow copy: references to nested mutable objects are shared between the original and the copy. Changing the outer list does not change the other outer list, but modifying a shared nested object is visible through both. Python documentation: Data Structures

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which method should you choose?

  • Add a single value at the end: append().
  • Add each value from an iterable: extend().
  • Insert before a particular index: insert().
  • Delete the first matching value: remove().
  • Delete an item by index and retrieve it: pop().
  • Find the first match or count matches: index() or count().
  • Change the list’s order: sort() or reverse().
  • Get a sorted result without changing the input: sorted().
  • Make a shallow outer-list copy: copy().

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.