Are Dictionaries Mutable or Immutable in Python Last Updated : 03 Dec, 2024 Comments Improve Suggest changes Like Article Like Report In Python, dictionaries are mutable. This means that you can modify the contents of a dictionary after it has been created. You can add, update or remove key-value pairs in a dictionary which makes it a flexible and dynamic data structure.What Does It Mean for Dictionaries to Be Mutable?Being mutable means that the state of the dictionary can change over time. You can perform several operations that modify the dictionary without needing to create a new one.The most common operation that demonstrate the mutability of dictionaries in Python is :Adding Key-Value PairsYou can add new key-value pairs to an existing dictionary: Python # Creating a dictionary dict = {'a': 1, 'b': 2} # Adding a new key-value pair dict['c'] = 3 print(dict) Output{'a': 1, 'b': 2, 'c': 3} In this case, we added a new key 'c' with the value 3 to the dictionary.Since, dictionary is mutable, we can perform more operations on dictionary like adding new values in dictionaryUpdating Existing Key-Value Pairs in Dictionaryremove a key from the dictionary delete items from dictionary while iterating Comment More infoAdvertise with us Next Article Are Dictionaries Mutable or Immutable in Python A anuragtriarna Follow Improve Article Tags : Python python-dict Practice Tags : pythonpython-dict Similar Reads Are Python Dictionaries Ordered? Yes, as of Python 3.7, dictionaries are ordered. This means that when you iterate over a dictionary, insert items, or view the contents of a dictionary, the elements will be returned in the order in which they were added. This behavior was initially an implementation detail in Python 3.6 (in the CPy 3 min read Are Lists Mutable in Python? Yes, lists are mutable in Python. This means that once a list is created, we can modify it by adding, removing or changing elements without creating a new list.Let's explore some examples that demonstrate how lists can be modified in Python:Changing Elements in a ListSince lists are mutable, you can 3 min read Dictionaries in Python Python dictionary is a data structure that stores the value in key: value pairs. Values in a dictionary can be of any data type and can be duplicated, whereas keys can't be repeated and must be immutable. Example: Here, The data is stored in key:value pairs in dictionaries, which makes it easier to 5 min read Merging or Concatenating two Dictionaries in Python Combining two dictionaries is a common task when working with Python, especially when we need to consolidate data from multiple sources or update existing records. For example, we may have one dictionary containing user information and another with additional details and we'd like to merge them into 2 min read Are Python Lists Mutable Yes, Python lists are mutable. This means you can change their content without changing their identity. You can add, remove, or modify items in a list after it has been created. Here are some examples demonstrating the mutability of Python lists: Example 1: Creating List Python my_list = [1, 2, 3] m 2 min read Like