In this video, we'll write a Python program to add a key:value pair into a dictionary.
1. Using dictionary subscript notation.
2. Using dictionary update() method.
Method 1: Using dictionary subscript notation: In this method, we can directly assign a value to any new key placed inside square brackets, to create a new key:value pair in the dictionary.
Method 2: Using dictionary update method: In this method, we update a dictionary with another dictionary. dictionary update() function updates the dictionary inplace with the new key:value pairs from the dictionary passed as a parameter to the update function.
Python program to add key:value pair into a dictionary: https://www.geeksforgeeks.org/add-a-keyvalue-pair-to-dictionary-in-python/