VOOZH about

URL: https://www.geeksforgeeks.org/python/appending-a-dictionary-to-a-list-in-python/

⇱ Appending a Dictionary to a List in Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Appending a Dictionary to a List in Python

Last Updated : 23 Jul, 2025

Appending a dictionary allows us to expand a list by including a dictionary as a new element. For example, when building a collection of records or datasets, appending dictionaries to a list can help in managing data efficiently. Let's explore different ways in which we can append a dictionary to a list in Python.

Using append()

append() method is the most straightforward and simple way to append a dictionary to a list.


Output
[{'name': 'kate', 'age': 25}, {'name': 'Nikki', 'age': 30}]

Explanation:

  • The append method directly adds the dictionary to the end of the list.
  • This is the most efficient and straightforward way to achieve the task.

Let's explore some other methods and see how we can append a dictionary to a list.

Using += Operator

+=Operator combines the list with a single dictionary by creating a list containing the dictionary. We can extend the list with a single dictionary wrapped in a list.


Output
[{'name': 'Kate', 'age': 25}, {'name': 'Nikki', 'age': 30}]

Explanation:

  • += operator modifies the original list in-place by concatenating it with another list.
  • Wrapping the dictionary in a list ensures compatibility with the += operation.

Using extend()

extend() method expects an iterable so we must wrap the dictionary inside a list. While typically this is used to add multiple elements it works with a single dictionary as well.


Output
[{'name': 'Kate', 'age': 25}, {'name': 'Nikki', 'age': 30}]

Explanation:

  • The dictionary is wrapped in a list and added to the existing list using extend.
  • This method is less efficient than append for single dictionaries.

Creating a New List with Concatenation

This method creates a new list by combining the existing list and the dictionary. + operator creates a new list without modifying the original list. This is useful when we want to retain the original list intact.


Output
[{'name': 'Kate', 'age': 25}, {'name': 'Nikki', 'age': 30}]

Explanation:

  • The dictionary is wrapped in a list and concatenated with the existing list.
  • Although this method works, it is less efficient due to the creation of a new list.
Comment