Python List insert() Method

list.insert() adds an item to a list at a specific position.

This method is useful when the position matters. For example, you may want to add a new value at the beginning of a list, in the middle, or just before the last item.

Use insert() when you need to place an item at a chosen index. If you only want to add an item at the end, see the Python list append() method.

numbers = [1, 2, 4]
numbers.insert(2, 3)
print(numbers)
# [1, 2, 3, 4]

Use list.insert(index, value) to add an item at a specific position.

What list.insert() does #

list.insert():

  • Adds one item into a list at a chosen position
  • Shifts existing items to the right
  • Changes the original list in place
  • Returns None

That last point is important. insert() does not create a new list.

Syntax #

my_list.insert(index, item)
  • index is the position where the new item should go
  • item is the value to add
  • The first list position is index 0

Example:

letters = ["a", "c"]
letters.insert(1, "b")
print(letters)

Output:

['a', 'b', 'c']

Here, "b" is inserted at index 1, so it appears between "a" and "c".

Basic example #

Here is a simple before-and-after example:

colors = ["red", "blue", "green"]
print("Before:", colors)

colors.insert(1, "yellow")
print("After: ", colors)

Output:

Before: ['red', 'blue', 'green']
After:  ['red', 'yellow', 'blue', 'green']

The new value appears at index 1. The existing items from that position onward move one place to the right.

How the index works #

The index in insert(index, item) controls where the new item is placed.

Insert at the beginning #

Use index 0 to add an item at the start of the list.

nums = [2, 3, 4]
nums.insert(0, 1)
print(nums)

Output:

[1, 2, 3, 4]

Insert in the middle #

A middle index inserts between existing items.

nums = [1, 2, 4]
nums.insert(2, 3)
print(nums)

Output:

[1, 2, 3, 4]

Insert past the end #

If the index is greater than the list length, Python adds the item at the end.

nums = [1, 2, 3]
nums.insert(10, 4)
print(nums)

Output:

[1, 2, 3, 4]

Use a negative index #

Negative indexes count from the end of the list. insert() places the item before that position.

letters = ["a", "b", "d"]
letters.insert(-1, "c")
print(letters)

Output:

['a', 'b', 'c', 'd']

If you are still getting comfortable with list positions, the Python lists beginner guide can help.

insert() vs append() #

These methods both add items to a list, but they do different jobs.

Use insert() when: #

  • You want to add an item at a specific position
  • The order of the list matters

Use append() when: #

  • You want to add an item only at the end
  • You do not need to choose a position

Example:

items = ["apple", "orange"]

items.insert(1, "banana")
print(items)

items.append("grape")
print(items)

Output:

['apple', 'banana', 'orange']
['apple', 'banana', 'orange', 'grape']

For the full method details, see the Python list append() method.

If your goal is the task itself rather than the method details, see how to add an item to a list in Python.

Common beginner mistakes #

Here are some common problems beginners run into with insert().

Assigning the result of insert() #

This is a very common mistake:

numbers = [1, 2, 3]
result = numbers.insert(1, 99)

print(result)
print(numbers)

Output:

None
[1, 99, 2, 3]

insert() changes the original list and returns None.

Wrong:

new_list = numbers.insert(1, 99)

Right:

numbers.insert(1, 99)

Passing arguments in the wrong order #

The correct order is:

my_list.insert(index, item)

Not:

my_list.insert(item, index)

Example:

letters = ["a", "c"]
letters.insert(1, "b")
print(letters)

Output:

['a', 'b', 'c']

Expecting insert() to replace an item #

insert() does not replace an existing value. It shifts items to the right.

numbers = [1, 2, 3]
numbers.insert(1, 99)
print(numbers)

Output:

[1, 99, 2, 3]

If you want to replace a value instead, use assignment:

numbers = [1, 2, 3]
numbers[1] = 99
print(numbers)

Output:

[1, 99, 3]

Trying to insert multiple items at once #

insert() adds one item each time.

This inserts a single list as one item:

numbers = [1, 4]
numbers.insert(1, [2, 3])
print(numbers)

Output:

[1, [2, 3], 4]

If you want to add many items, see the Python list extend() method.

Helpful checks while debugging #

If insert() is not doing what you expect, these can help:

print(my_list)
print(len(my_list))
print(my_list.insert.__doc__)
help(list.insert)
type(my_list)

These checks can help you confirm:

  • What is currently in the list
  • How long the list is
  • That you are working with a real list
  • How Python describes the method

When to use insert() #

Use insert() when position matters.

Common cases:

  • Ordered menus
  • Rankings or score lists
  • Step-by-step manual list building
  • Inserting a value at the beginning or middle

You usually do not need insert() when adding only to the end of a list. In that case, append() is simpler.

If you need a refresher on making lists before using methods on them, see creating a list in Python.

FAQ #

Does list.insert() return a new list? #

No. It changes the existing list and returns None.

What happens if the index is bigger than the list length? #

Python adds the item at the end of the list.

Can list.insert() add multiple items? #

It adds one item each time. To add many items, use extend() or slicing.

What is the difference between insert() and append()? #

insert() adds at a chosen position. append() adds only at the end.

See also #

Press Esc to close