From f4a62a9e058c7535e6a2e79e07f9844bce91f926 Mon Sep 17 00:00:00 2001 From: Amulya Sharma Date: Wed, 19 Aug 2026 16:06:43 -0700 Subject: [PATCH] Simplify dict update example to use literal key instead of unpacking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The {**my_dict, **{'cool': True}} form is more verbose than needed for adding a single key — {**my_dict, 'cool': True} does the same thing. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8525fc..715d367 100644 --- a/README.md +++ b/README.md @@ -281,7 +281,7 @@ my_dict.pop('name', None) ```python my_dict.update({'cool': True}) # {'name': 'Andrei Neagoie', 'age': 30, 'magic_power': False, 'favourite_snack': 'Grapes', 'cool': True} -{**my_dict, **{'cool': True} } # {'name': 'Andrei Neagoie', 'age': 30, 'magic_power': False, 'favourite_snack': 'Grapes', 'cool': True} +{**my_dict, 'cool': True} # {'name': 'Andrei Neagoie', 'age': 30, 'magic_power': False, 'favourite_snack': 'Grapes', 'cool': True} new_dict = dict([['name','Andrei'],['age',32],['magic_power',False]]) # Creates a dict from collection of key-value pairs. new_dict = dict(zip(['name','age','magic_power'],['Andrei',32, False]))# Creates a dict from two collections. new_dict = my_dict.pop('favourite_snack') # Removes item from dictionary.