This post will discuss how to insert an item at the end of a list in Python.

1. Using list.append(x) function

You can add new items at the end of the list by using the append() function:

Download  Run Code

2. Using list.insert(i, x) function

You can also use the list’s insert() function that inserts an item at the specified position.

Download  Run Code

3. Using Iterable Unpacking Operator

Another plausible way of insertion at the end is using the * iterable unpacking operator. This feature was introduced with Python 3.5 by the acceptance of PEP 448 – Additional Unpacking Generalizations.

Download  Run Code

4. Creating a new list

Another approach is to convert the given item into a list first and then concatenate it to the existing list. Note that this solution is slower than all the above solutions since it creates a new list.

Download  Run Code

That’s all about inserting an item at the end of a list in Python.