Python’s list.append(item) adds exactly one object to the end of an existing list. It works for strings, numbers, dictionaries and nested lists; the method mutates the list and returns None.
Syntax of the Append()
list.append(element)
How Does Append() Method Works
The method takes a single argument.
element – an element to be added at the end of the list
The element can be numbers, strings, dictionaries, another list, and so on. The method doesn’t return any value.
Append a Single Element at the End of List
# Creating a list
list_example = [1,2,3,'PickupBrain']
print("List: ",list_example)
# Adding "Learn Python" in list
list_example.append("Learn Python")
# Updated list is
print('Updated list: ', list_example)
The output will be
[1, 2, 3, 'PickupBrain']
Updated list: [1, 2, 3, 'PickupBrain', 'Learn Python']
Adding List in List
The problem of inserting a number at any index is a quite common one. But sometimes the requirement to insert the whole list into another list. These kinds of problems occur in Machine Learning while playing with data. This is also known as Nested List.
#Creating a First List
List_1 = [1,2,3,4,5]
print("First List: ",List_1)
print("The Length of First List: ",len(List_1))
# Creating a Second List
List_2 = ['PickupBrain', "Learn Python",123]
print("Second List: ",List_2)
print("The Length of Second List: ",len(List_2))
# Appending List_2 to the List_1
List_1.append(List_2)
print('Updated List: ', List_1)
print("The Length of Updated List: ",len(List_1))
The output will be
Output:
First List: [1, 2, 3, 4, 5]
The Length of First List: 5
Second List: ['PickupBrain', 'Learn Python', 123]
The Length of Second List: 3
Updated List: [1, 2, 3, 4, 5, ['PickupBrain', 'Learn Python', 123]]
The Length of Updated List: 6
Conclusion
Adding an element at the end of the List is very simple and easy in Python. However if you try to append a list into another list using this method, the entire list is added as a single element to the original list. Irrespective of the size of appended data, length of the original list is always increased by one. To avoid this problem, use extend method.
Also read :
Length of List in Python
Updated explanation and practical examples
Example: values = [1, 2]; values.append([3, 4]) gives [1, 2, [3, 4]], not [1, 2, 3, 4]. To add the elements separately, use values.extend([3, 4]). Avoid assigning values = values.append(5): the assignment replaces your list variable with None. append() is typically amortized O(1), but resizing can make individual calls slower.
Frequently asked questions
Q: Does append copy its argument? A: No; when appending a mutable object such as another list, the nested object is referenced, so later changes to it can appear in the containing list. Q: Can I append to a tuple? A: No; tuples are immutable. Q: How do I add at the beginning? A: Use insert(0, item), or collections.deque for frequent left-end operations.

C P Gupta is a YouTuber and Blogger. He is expert in Microsoft Word, Excel and PowerPoint. His YouTube channel @pickupbrain is very popular and has crossed 9.9 Million Views.