October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

Python List append(), insert(), and extend(): What Each Method Does

Python’s append(), extend(), and insert() all modify a list in place—but they add values differently. See examples and learn which one fits your task.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use append() to add one item at the end of a list, extend() to add the items from an iterable at the end, and insert() to place one item at a chosen index. All three modify the existing list and return None.

How the three methods change a list

Method What you pass What it adds Where it adds it Return value
append(value) One value That value as one item At the end None
extend(iterable) An iterable Each item yielded by the iterable At the end None
insert(index, value) An index and one value That value as one item Before the item at the index None

These are in-place operations: they change the list you call them on rather than creating and returning a separate updated list. The Python 3.14.8 tutorial describes append() as similar to assigning a one-item list to the slice at the end, and extend() as similar to assigning the iterable there.

When to use append()

Choose append() when you want to add one value as a single new element at the end. The value itself can be another list or collection; append() does not unpack it.

items = ["a", "b"]
items.append(["c", "d"])
print(items)
# ['a', 'b', ['c', 'd']]

The nested list is one item inside items. Use append() when preserving the added object as a single element is the goal.

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

When to use extend()

Choose extend() when you want to add the items from an iterable individually to the end of a list. Lists, tuples, and strings are examples of iterables described in the Python 3.14.8 built-in types reference.

items = ["a", "b"]
items.extend(["c", "d"])
print(items)
# ['a', 'b', 'c', 'd']

Because a string is iterable, extending with "cat" adds its characters individually, while appending "cat" adds the whole string as one item:

items = []
items.append("cat")
print(items)
# ['cat']

items = []
items.extend("cat")
print(items)
# ['c', 'a', 't']

When to use insert()

Choose insert(index, value) when you want to add one item at a particular position. The new value goes before the item currently at that index.

items = ["a", "b"]
items.insert(1, "x")
print(items)
# ['a', 'x', 'b']
  • items.insert(0, value) puts the value at the front.
  • items.insert(len(items), value) adds it at the end, equivalent to items.append(value).

Inserting near the beginning requires the following list elements to shift position. The tutorial notes that inserting or popping at the beginning is slow compared with end operations.

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

Why assigning a method call back to the list is a bug

Since these methods return None, do not assign their result back to the list. This common mistake discards the list reference:

items = ["a", "b"]
items = items.append("c")
print(items)
# None

Call the method on its own line instead:

items = ["a", "b"]
items.append("c")
print(items)
# ['a', 'b', 'c']
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choosing a list operation for stacks and queues

For a list-backed stack, adding and removing items at the end is a suitable pattern. For a first-in, first-out queue, repeatedly inserting at index zero can require shifting the other elements. The Python tutorial recommends collections.deque for queues that need fast appends and pops at both ends; see its list and deque guidance.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.