Last modified: May 24, 2026
Python List Insert at Beginning
Adding an item to the start of a Python list is a common task. You might need to prepend data for queue operations, maintain order, or build a list from scratch. Python offers several clean ways to do this.
This guide covers the main methods. We will focus on list.insert(), slicing, and the + operator. Each method has its use case. We will also discuss performance to help you choose the right one.
Using the insert() Method
The most direct way is the insert() method. It takes two arguments: the index and the element. To insert at the beginning, use index 0.
This method modifies the list in place. It shifts all existing elements one position to the right.
# Create a list
fruits = ['banana', 'cherry', 'date']
# Insert 'apple' at the beginning (index 0)
fruits.insert(0, 'apple')
print(fruits)
['apple', 'banana', 'cherry', 'date']
The insert() method is simple and readable. It is perfect for inserting a single item. For a deeper look at this method, see our Python List Insert: Complete Guide.
Using Slicing to Insert at Beginning
You can also use slicing to prepend an item. This creates a new list. It does not modify the original list.
The syntax is list[:0] = [element]. This assigns the new element to the slice at index 0.
# Original list
numbers = [2, 3, 4]
# Insert 1 at the beginning using slicing
numbers[:0] = [1]
print(numbers)
[1, 2, 3, 4]
This method is useful when you want to insert multiple items at once. For example, numbers[:0] = [0, 1] inserts two elements at the start. You can learn more about inserting multiple items in our Python List Insert Multiple Items article.
Using the + Operator to Prepend
The + operator concatenates two lists. To prepend an item, wrap it in a list and add it to the front.
This method always creates a new list. It is clean for one-time operations.
# Original list
colors = ['red', 'green', 'blue']
# Prepend 'yellow' using + operator
new_colors = ['yellow'] + colors
print(new_colors)
['yellow', 'red', 'green', 'blue']
This approach is very readable. However, it creates a copy of the original list. If you need to keep the original list unchanged, this is a good choice.
Performance Considerations
Inserting at the beginning of a Python list is not an O(1) operation. Lists are implemented as dynamic arrays. When you insert at index 0, all other elements must shift one position to the right.
This operation has a time complexity of O(n). For small lists, this is fine. For large lists, it can be slow.
If you frequently insert at the beginning, consider using a collections.deque. It is optimized for fast appends and pops from both ends. The deque.appendleft() method runs in O(1) time.
You can read more about the time complexity of list operations in our Python List Insert Time Complexity guide.
Inserting Multiple Items at Beginning
Sometimes you need to insert multiple items at the start. The slicing method handles this well. You can also use insert() in a loop, but that is less efficient.
Here is an example using slicing to insert a list of items at the beginning.
# Original list
letters = ['c', 'd', 'e']
# Insert 'a' and 'b' at the beginning
letters[:0] = ['a', 'b']
print(letters)
['a', 'b', 'c', 'd', 'e']
This method is clean and efficient. It inserts all items in one operation. For more examples, check our article on Python List Insert Multiple Items.
Common Mistakes to Avoid
One common mistake is using insert() with a negative index. Negative indices count from the end. For example, list.insert(-1, value) inserts before the last element, not at the beginning.
Another mistake is forgetting that insert() modifies the list in place and returns None. Do not assign the result to a variable.
# Wrong: assigning return value
my_list = [1, 2, 3]
result = my_list.insert(0, 0) # result is None
print(result) # None
# Correct: just call the method
my_list.insert(0, 0)
print(my_list) # [0, 1, 2, 3]
When to Use Each Method
Use insert(0, item) for a single item when you want to modify the list in place. It is the most readable option.
Use slicing when you want to insert multiple items or prefer a more functional style. It is also good when you want to avoid a loop.
Use the + operator when you need a new list and want to keep the original unchanged. It is very clear in intent.
For high-frequency prepends, switch to collections.deque. This will save you time and memory.
Conclusion
Inserting an element at the beginning of a Python list is easy. The insert() method with index 0 is the standard way. Slicing and the + operator offer alternatives for specific needs.
Always consider performance for large lists. Use deque if you need many prepends. Now you have the tools to prepend items effectively in your Python projects.