{"id":22510,"date":"2021-11-19T16:37:56","date_gmt":"2021-11-19T11:07:56","guid":{"rendered":"https:\/\/tutorial.eyehunts.com\/?p=22510"},"modified":"2023-05-16T17:14:19","modified_gmt":"2023-05-16T11:44:19","slug":"python-update-nested-dictionary-example-code","status":"publish","type":"post","link":"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/","title":{"rendered":"Python update nested dictionary | Example code"},"content":{"rendered":"\n<p>The dictionaries within a dictionary are called a <strong>Nested dictionaries <\/strong>in Python. You can update the nested dictionary using the assignment operator or <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-set-update-method-example-code\/\">update method<\/a> in Python.<\/p>\n\n\n\n<p>Yes, updating the Nested dictionary is similar to updating a simple dictionary. Here&#8217;s the syntax for updating a nested dictionary in Python:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nested_dict&#91;key1]&#91;key2] = new_value\r<\/code><\/pre>\n\n\n\n<p>In the above syntax:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>nested_dict<\/code> refers to the original nested dictionary.<\/li>\n\n\n\n<li><code>key1<\/code> is the outer key of the nested dictionary.<\/li>\n\n\n\n<li><code>key2<\/code> is the inner key within <code>key1<\/code>.<\/li>\n\n\n\n<li><code>new_value<\/code> is the value you want to assign to the specified key within the nested dictionary.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Example update nested dictionary in Python<\/strong><\/h2>\n\n\n\n<p>Simple example code.<\/p>\n\n\n\n<p><strong>Appending nested list<\/strong><\/p>\n\n\n\n<p>It will add a new key value to a dictionary.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Employee = {\n    'emp1': {\n        'name': 'John',\n        'age': '29',\n        'Designation': 'Programmer'\n    },\n    'emp2': {\n        'name': 'Steve',\n        'age': '45',\n        'Designation': 'HR'\n    }\n}\n\nEmployee&#91;'name'] = 'Kate'\n\nprint(Employee)\n\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>:<\/p>\n\n\n\n<p>{&#8217;emp1&#8242;: {&#8216;name&#8217;: &#8216;John&#8217;, &#8216;age&#8217;: &#8217;29&#8217;, &#8216;Designation&#8217;: &#8216;Programmer&#8217;}, &#8217;emp2&#8242;: {&#8216;name&#8217;: &#8216;Steve&#8217;, &#8216;age&#8217;: &#8217;45&#8217;, &#8216;Designation&#8217;: &#8216;HR&#8217;}, &#8216;name&#8217;: &#8216;Kate&#8217;}<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Updating existing key values in the Nested dictionary.<\/strong><\/p>\n\n\n\n<p>This example updates the value for the mentioned key if it is present in the dictionary. Otherwise, it creates a new entry.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Employee = {\n    'emp1': {\n        'name': 'John',\n        'age': '29',\n        'Designation': 'Programmer'\n    },\n    'emp2': {\n        'name': 'Steve',\n        'age': '45',\n        'Designation': 'HR'\n    }\n}\nEmployee&#91;'emp1']&#91;'name'] = 'Kate'\nprint(Employee)\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"497\" height=\"198\" src=\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Python-update-nested-dictionary.jpg?resize=497%2C198&#038;ssl=1\" alt=\"Python update nested dictionary\" class=\"wp-image-22537\"\/><\/figure><\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Comment if you have any doubts or suggestions on this Python dictionary topic.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note:<\/strong> IDE:&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.jetbrains.com\/pycharm\/\" target=\"_blank\">PyCharm<\/a>&nbsp;2021.3.3 (Community Edition)<\/p><p>Windows 10<\/p><p><strong>Python 3.10.1<\/strong><\/p><p>All<strong>&nbsp;Python Examples&nbsp;are in&nbsp;Python&nbsp;3<\/strong>, so Maybe its different from python 2 or upgraded versions.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>The dictionaries within a dictionary are called a Nested dictionaries in Python. You can update the nested dictionary using the assignment operator or update method in Python. Yes, updating the Nested dictionary is similar to updating a simple dictionary. Here&#8217;s the syntax for updating a nested dictionary in Python: In the above syntax: Example update&hellip;&nbsp;<a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Python update nested dictionary | Example code<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[30],"tags":[101,261],"post_series":[],"class_list":["post-22510","post","type-post","status-publish","format-standard","hentry","category-python","tag-python-dictionary","tag-python-update"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python update nested dictionary | Example code<\/title>\n<meta name=\"description\" content=\"The dictionaries within a dictionary are called a Nested dictionary in Python. You can update the nested dictionary using the assignment...\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python update nested dictionary | Example code\" \/>\n<meta property=\"og:description\" content=\"The dictionaries within a dictionary are called a Nested dictionary in Python. You can update the nested dictionary using the assignment...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-19T11:07:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-16T11:44:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Python-update-nested-dictionary.jpg\" \/>\n<meta name=\"author\" content=\"Rohit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rohit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/\",\"name\":\"Python update nested dictionary | Example code\",\"isPartOf\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Python-update-nested-dictionary.jpg\",\"datePublished\":\"2021-11-19T11:07:56+00:00\",\"dateModified\":\"2023-05-16T11:44:19+00:00\",\"author\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\"},\"description\":\"The dictionaries within a dictionary are called a Nested dictionary in Python. You can update the nested dictionary using the assignment...\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Python-update-nested-dictionary.jpg?fit=497%2C198&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Python-update-nested-dictionary.jpg?fit=497%2C198&ssl=1\",\"width\":497,\"height\":198},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorial.eyehunts.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python update nested dictionary | Example code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\",\"url\":\"https:\/\/tutorial.eyehunts.com\/\",\"name\":\"Tutorial\",\"description\":\"By EyeHunts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\",\"name\":\"Rohit\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971\",\"contentUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971\",\"caption\":\"Rohit\"},\"description\":\"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.\",\"url\":\"https:\/\/tutorial.eyehunts.com\/author\/rohit\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python update nested dictionary | Example code","description":"The dictionaries within a dictionary are called a Nested dictionary in Python. You can update the nested dictionary using the assignment...","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/","og_locale":"en_US","og_type":"article","og_title":"Python update nested dictionary | Example code","og_description":"The dictionaries within a dictionary are called a Nested dictionary in Python. You can update the nested dictionary using the assignment...","og_url":"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/","og_site_name":"Tutorial","article_published_time":"2021-11-19T11:07:56+00:00","article_modified_time":"2023-05-16T11:44:19+00:00","og_image":[{"url":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Python-update-nested-dictionary.jpg","type":"","width":"","height":""}],"author":"Rohit","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rohit","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/","url":"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/","name":"Python update nested dictionary | Example code","isPartOf":{"@id":"https:\/\/tutorial.eyehunts.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/#primaryimage"},"image":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/#primaryimage"},"thumbnailUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Python-update-nested-dictionary.jpg","datePublished":"2021-11-19T11:07:56+00:00","dateModified":"2023-05-16T11:44:19+00:00","author":{"@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1"},"description":"The dictionaries within a dictionary are called a Nested dictionary in Python. You can update the nested dictionary using the assignment...","breadcrumb":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/#primaryimage","url":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Python-update-nested-dictionary.jpg?fit=497%2C198&ssl=1","contentUrl":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Python-update-nested-dictionary.jpg?fit=497%2C198&ssl=1","width":497,"height":198},{"@type":"BreadcrumbList","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-update-nested-dictionary-example-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorial.eyehunts.com\/"},{"@type":"ListItem","position":2,"name":"Python update nested dictionary | Example code"}]},{"@type":"WebSite","@id":"https:\/\/tutorial.eyehunts.com\/#website","url":"https:\/\/tutorial.eyehunts.com\/","name":"Tutorial","description":"By EyeHunts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1","name":"Rohit","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/","url":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971","contentUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971","caption":"Rohit"},"description":"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.","url":"https:\/\/tutorial.eyehunts.com\/author\/rohit\/"}]}},"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":22415,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-copy-dictionary-into-another-example-code\/","url_meta":{"origin":22510,"position":0},"title":"Python copy dictionary into another | Example code","author":"Rohit","date":"November 23, 2021","format":false,"excerpt":"Use the assignment operator to shallow copy a dictionary into another in Python. But if you want to use deep copy then use the deepcopy() method. Example copy a dictionary into another in Python Simple example code assign dict2 = dict1, not making a copy of dict1, it results in\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python copy dictionary into another","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Python-copy-dictionary-into-another.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":23486,"url":"https:\/\/tutorial.eyehunts.com\/python\/how-to-add-the-same-key-value-in-dictionary-python-example-code\/","url_meta":{"origin":22510,"position":1},"title":"How to add the same key value in dictionary Python | Example code","author":"Rohit","date":"December 18, 2021","format":false,"excerpt":"Python Dictionary does not support the same name keys. You can't use the same key multiple times because the Python dictionary must be unique. However, you can use the list to add the same key for multiple values in dictionary Python. Where more than one value can correspond to a\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"How to add the same key value in dictionary Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/How-to-add-the-same-key-value-in-dictionary-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":22512,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-dictionary-update-value-if-the-key-exists-example-code\/","url_meta":{"origin":22510,"position":2},"title":"Python dictionary update value if the key exists | Example code","author":"Rohit","date":"November 19, 2021","format":false,"excerpt":"Use the \"in\" keyword to check if keys exist. If exist then update the value of the dictionary in Python. If the key exists, we update its value by assigning a new value to the key using the assignment operator (=). Example dictionary update value if the key exists in\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python dictionary update value if key exists","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Python-dictionary-update-value-if-key-exists.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":18729,"url":"https:\/\/tutorial.eyehunts.com\/python\/add-list-to-dictionary-python-example-code\/","url_meta":{"origin":22510,"position":3},"title":"Add list to dictionary Python | Example code","author":"Rohit","date":"October 29, 2021","format":false,"excerpt":"One way is to Add a list to the dictionary by Adding a nested list as a value using the append() method in Python. Create a new list and we can simply append that list to the value. Example Add list to dictionary Python Simple example code. The restriction with\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Add list to dictionary Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Add-list-to-dictionary-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":40695,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-frozendict\/","url_meta":{"origin":22510,"position":4},"title":"Python frozendict","author":"Rohit","date":"July 5, 2023","format":false,"excerpt":"The concept of a frozendict does not exist in the standard Python library. However, you can create an immutable dictionary-like object by using the types.MappingProxyType class from the types module. This class creates a read-only view of a dictionary. import types original_dict = {'key1': 'value1', 'key2': 'value2'} frozen_dict = types.MappingProxyType(original_dict)\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/07\/Python-frozendict.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/07\/Python-frozendict.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/07\/Python-frozendict.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":18672,"url":"https:\/\/tutorial.eyehunts.com\/python\/get-value-by-key-dictionary-python-example-code\/","url_meta":{"origin":22510,"position":5},"title":"Get value by key dictionary Python | Example code","author":"Rohit","date":"December 2, 2021","format":false,"excerpt":"Simple use square bracket [] with a key on dictionary object to Get value by key dictionary Python. dict[key] Note: KeyError occurs if the key does not exist. Or Use gets () method of the dictionary object dict to get any default value without raising an error if the key\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Get value by key dictionary Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/Get-value-by-key-dictionary-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/22510","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/comments?post=22510"}],"version-history":[{"count":1,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/22510\/revisions"}],"predecessor-version":[{"id":39396,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/22510\/revisions\/39396"}],"wp:attachment":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/media?parent=22510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/categories?post=22510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/tags?post=22510"},{"taxonomy":"post_series","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/post_series?post=22510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}