{"id":17565,"date":"2020-11-18T16:43:21","date_gmt":"2020-11-19T00:43:21","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=17565"},"modified":"2023-12-01T04:04:11","modified_gmt":"2023-12-01T12:04:11","slug":"python-nested-dictionary","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/","title":{"rendered":"Python Nested Dictionary: A How-To Guide"},"content":{"rendered":"\n<p><em>A Python nested dictionary is a dictionary within another dictionary. This lets you store data using the key-value mapping structure within an existing dictionary. <\/em><\/p>\n\n\n\n<p>When you\u2019re working with dictionaries in Python, you may encounter a situation where a dictionary contains another dictionary.\n\n<\/p>\n\n\n\n<p>This structure of data is often referred to as a <em>nested dictionary,<\/em> and has a wide range of potential use cases in Python code.\n\n<\/p>\n\n\n\n<p>This tutorial will discuss the basics of Python nested dictionaries. We&#8217;ll walk through a few examples so you can learn how to create and modify a nested dictionary.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Dictionary Refresher<\/h2>\n\n\n\n<p>The dictionary is Python\u2019s mapping data type. A <a href=\"https:\/\/careerkarma.com\/blog\/python-dictionary-values\/\">Python dictionary<\/a> binds\u2014or <em>map<\/em>\u2014keys to values, and provide an effective way of storing data.\n\n<\/p>\n\n\n\n<p>When a key is mapped to a value, you can retrieve the data stored in that value by referencing the key. So, in a sense, the key acts like a label. Here\u2019s an example of a dictionary which stores the prices of ice cream flavors sold at a local ice cream store, The Frozen Spoon:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>ice_cream_flavors = {\n\t&quot;Vanilla&quot;: 0.50,\n\t&quot;Chocolate&quot;: 0.50,\n\t&quot;Cookies and Cream&quot;: 0.75,\n\t&quot;Strawberry&quot;: 0.65,\n\t&quot;Buttered Pecan&quot;: 0.90\n}\n<\/pre><\/div>\n\n\n\n<p>The keys in this dictionary are the names of our ice creams (i.e. \u201cVanilla\u201d), and the values are the prices per scoop of each ice cream.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Nested Dictionary<\/h2>\n\n\n\n<p>Python nested dictionaries are dictionaries inside a dictionary. They are used to represent dictionary data within another dictionary. You can nest as many dictionaries in a dictionary as you want.<\/p>\n\n\n\n<p>Nested dictionaries are useful if you want to store a range of component dictionaries in one big dictionary.\n\n<\/p>\n\n\n\n<p>Let\u2019s walk through an example to illustrate how nested dictionaries work. Suppose we want to create a dictionary which stores dictionaries about each flavor of ice cream sold at The Frozen Spoon. Each dictionary in our big dictionary should list:\n\n<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The name of the ice cream<\/li><li>Its price<\/li><li>How many pints are in stock<\/li><\/ul>\n\n\n\n<p>Here is what a nested dictionary that stores this data would look like:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>ice_cream_flavors = {\n\t0: { &quot;flavor&quot;: &quot;Vanilla&quot;, &quot;price&quot;: 0.50, &quot;pints&quot;: 20 },\n\t1: { &quot;flavor&quot;: &quot;Chocolate&quot;, &quot;price&quot;: 0.50, &quot;pints&quot;: 31 },\n2: { &quot;flavor&quot;: &quot;Cookies and Cream&quot;, &quot;price&quot;: 0.75, &quot;pints&quot;: 14 }\n}\n<\/pre><\/div>\n\n\n\n<p>In our code, we have declared one big dictionary called <em>ice_cream_flavors<\/em>. This dictionary contains three dictionaries, each of which stores information on a particular flavor of ice cream.\n\n<\/p>\n\n\n\n<p>If we did not use a nested dictionary, we would have had to store each of these dictionaries in separate variables. This is counterintuitive because each dictionary stores information about ice cream flavors.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Access Items in a Nested Dictionary<\/h2>\n\n\n\n<p>To access an item in a nested dictionary, we can use the indexing syntax.\n\n<\/p>\n\n\n\n<p>Suppose we want to retrieve the price of the ice cream with the index value 0 in our dictionary. We could do so using this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>ice_cream_flavors = {\n\t0: { &quot;flavor&quot;: &quot;Vanilla&quot;, &quot;price&quot;: 0.50, &quot;pints&quot;: 20 },\n\t1: { &quot;flavor&quot;: &quot;Chocolate&quot;, &quot;price&quot;: 0.50, &quot;pints&quot;: 31 },\n2: { &quot;flavor&quot;: &quot;Cookies and Cream&quot;, &quot;price&quot;: 0.75, &quot;pints&quot;: 14 }\n}\n\nprint(ice_cream_flavors[0][&quot;price&quot;])\nprint(ice_cream_flavors[0][&quot;flavor&quot;])\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>0.50\nVanilla<\/pre><\/div>\n\n\n\n<p>In this code, we first specify the item key whose value is in our big dictionary that we want to retrieve. In this case, we wanted to access the record with the index value 0.\n\n<\/p>\n\n\n\n<p>Then, we specify the name of the item in our inner dictionary that we want to retrieve. In this case, we wanted to retrieve the price of our ice cream and the flavor. So, we specified <em>price<\/em> and <em>flavor<\/em> in both our <em>print() <\/em>statements.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Nested Dictionary Python: Add Element<\/h2>\n\n\n\n<p>To add an element to a nested dictionary, we can use the same syntax we used to modify an item. There is no method you should use to add an item to a nested dictionary. You need to use the assignment operator.<\/p>\n\n\n\n<p>The syntax for adding an item is as follows:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>dictionary_name[new_key_name] = new_value<\/pre><\/div>\n\n\n\n<p>Suppose we have a dictionary that stores information on a vanilla ice cream for sale. We want to track whether there is a discount on the ice cream. We could do this using the following code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>ice_cream_flavors = {\n\t0: { &quot;flavor&quot;: &quot;Vanilla&quot;, &quot;price&quot;: 0.50, &quot;pints&quot;: 20 },\n\t1: { &quot;flavor&quot;: &quot;Chocolate&quot;, &quot;price&quot;: 0.50, &quot;pints&quot;: 31 },\n2: { &quot;flavor&quot;: &quot;Cookies and Cream&quot;, &quot;price&quot;: 0.75, &quot;pints&quot;: 14 }\n}\n\nice_cream_flavors[0][&quot;discount&quot;] = True\n\nprint(ice_cream_flavors[0])\n<\/pre><\/div>\n\n\n\n<p>Let&#8217;s run our code and see what happens:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>{'flavor': 'Vanilla', 'price': 0.5, 'pints': 20, 'discount': True}<\/pre><\/div>\n\n\n\n<p>Our dictionary is stored in the <a href=\"https:\/\/careerkarma.com\/blog\/python-variables\/\">Python variable<\/a> &#8220;ice_cream_flavors&#8221;.<\/p>\n\n\n\n<p>We added a key called <em>discount<\/em> to the dictionary. The index position of this key is 0. We set the value of this key to True. Then, we printed out the dictionary with the index value 0 in our <em>ice_cream_flavors<\/em> nested dictionary. This shows that our <em>discount<\/em> key has been added.<\/p>\n\n\n\n<p>We can use this syntax to update an element in an existing dictionary. Suppose we wanted to change the price of our chocolate ice cream to be $0.45 per scoop. We could do so using this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>ice_cream_flavors = {\n\t0: { &quot;flavor&quot;: &quot;Vanilla&quot;, &quot;price&quot;: 0.50, &quot;pints&quot;: 20 },\n\t1: { &quot;flavor&quot;: &quot;Chocolate&quot;, &quot;price&quot;: 0.50, &quot;pints&quot;: 31 },\n2: { &quot;flavor&quot;: &quot;Cookies and Cream&quot;, &quot;price&quot;: 0.75, &quot;pints&quot;: 14 }\n}\n\nice_cream_flavors[1][&quot;price&quot;] = 0.45\n\nprint(ice_cream_flavors[1])\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>{'flavor': 'Chocolate', 'price': 0.45, 'pints': 31}<\/pre><\/div>\n\n\n\n<p>We changed the value of the <em>price<\/em> key for our chocolate ice cream to be $0.45.\n\n<\/p>\n\n\n\n<p>To do so, we specified the index value of the dictionary whose <em>price<\/em> value we wanted to change as 1. This value contains the information about chocolate ice creams in our dictionary. Then, we assigned a new value to the <em>price<\/em> key.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Nested Dictionary Python: Delete Element<\/h2>\n\n\n\n<p>To delete an item stored in a nested dictionary, we can use the <em>del<\/em> statement. The del statement lets you delete an object. del is written like a <a href=\"https:\/\/careerkarma.com\/blog\/python-break-and-continue\/\">Python break statement<\/a>, on its own line, followed by the item in the dictionary that you want to delete.<\/p>\n\n\n\n<p>Suppose we are no longer offering cookies and cream ice cream at our store temporarily. Our freezer that stored the cookies and cream ice cream stopped working and the goods melted.\n\n<\/p>\n\n\n\n<p>We could remove this ice cream from our nested dictionary using the following code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>ice_cream_flavors = {\n\t0: { &quot;flavor&quot;: &quot;Vanilla&quot;, &quot;price&quot;: 0.50, &quot;pints&quot;: 20 },\n\t1: { &quot;flavor&quot;: &quot;Chocolate&quot;, &quot;price&quot;: 0.50, &quot;pints&quot;: 31 },\n2: { &quot;flavor&quot;: &quot;Cookies and Cream&quot;, &quot;price&quot;: 0.75, &quot;pints&quot;: 14 }\n}\n\ndel ice_cream_flavors[2]\n\nprint(ice_cream_flavors)\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>{0: {'flavor': 'Vanilla', 'price': 0.5, 'pints': 20}, 1: {'flavor': 'Chocolate', 'price': 0.5, 'pints': 31}}<\/pre><\/div>\n\n\n\n<p>In our code, we used a <em>del<\/em> statement to delete the value in our nested dictionary whose key was equal to 2. As you can see, this removed the entry for <em>Cookies and Cream<\/em> from our nested dictionary.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Iterate Through a Python Nested Dictionary<\/h2>\n\n\n\n<p>Now, suppose we want to print out the contents of each dictionary in our nested dictionary to the console. How can we accomplish this task?\n\n<\/p>\n\n\n\n<p>That\u2019s a great question. To print out the contents of our nested dictionary, we can iterate through it using a <a href=\"https:\/\/careerkarma.com\/blog\/python-for-loop\/\">Python for loop<\/a>. We are also going to use the <a href=\"https:\/\/careerkarma.com\/blog\/iterate-through-dictionary-python\/\">Python dictionary items() method<\/a> to retrieve a list of the keys and values in our dictionary:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>ice_cream_flavors = {\n\t0: { &quot;flavor&quot;: &quot;Vanilla&quot;, &quot;price&quot;: 0.50, &quot;pints&quot;: 20 },\n\t1: { &quot;flavor&quot;: &quot;Chocolate&quot;, &quot;price&quot;: 0.50, &quot;pints&quot;: 31 },\n2: { &quot;flavor&quot;: &quot;Cookies and Cream&quot;, &quot;price&quot;: 0.75, &quot;pints&quot;: 14 }\n}\n\nfor key, value in ice_cream_flavors.items():\n\tprint(&quot;Ice Cream:&quot;, key)\n\n\tfor k, v in value.items():\n\t\tprint(k + &quot;:&quot;, value[k])\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Ice Cream: 0\nflavor: Vanilla\nprice: 0.5\npints: 20\nIce Cream: 1\nflavor: Chocolate\nprice: 0.5\npints: 31\nIce Cream: 2\nflavor: Cookies and Cream\nprice: 0.75\npints: 14<\/pre><\/div>\n\n\n\n<p>Let\u2019s break down our code. First, we have defined our nested dictionary of ice cream flavors.\n\n<\/p>\n\n\n\n<p>Then, we have defined a for loop that goes through each key and value in the <em>ice_cream_flavors<\/em> dictionary. This loop uses <em>.items()<\/em> to generate a list of all the keys and values in our <em>ice_cream_flavors<\/em> dictionary, over which the loop can iterate.\n\n<\/p>\n\n\n\n<p>Then, we print <em>Ice Cream:<\/em> followed by the key associated with a particular ice cream.\n\n<\/p>\n\n\n\n<p>Next, we use another for loop to loop through every item in each <em>value<\/em> in our nested dictionary. This refers to each inner entry in our nested dictionary (such as the ones for vanilla and chocolate). This loop prints out the name of each key in our inner dictionaries, followed by a colon, then the value associated with that key.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Nested dictionaries allow you to store dictionaries inside a dictionary in Python.\n\n<\/p>\n\n\n\n<p>This tutorial discussed, with reference to examples, how to:\n\n<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Create a nested dictionary<\/li><li>Add elements to and update elements in a nested dictionary<\/li><li>Remove elements from a nested dictionary<\/li><li>Iterate through a nested dictionary<\/li><\/ul>\n\n\n\n<p>To learn more about coding in Python, read our <a href=\"https:\/\/careerkarma.com\/blog\/how-to-learn-python\/\">How to Code in Python guide<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"A Python nested dictionary is a dictionary within another dictionary. This lets you store data using the key-value mapping structure within an existing dictionary. When you\u2019re working with dictionaries in Python, you may encounter a situation where a dictionary contains another dictionary. This structure of data is often referred to as a nested dictionary, and&hellip;","protected":false},"author":240,"featured_media":17631,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-17565","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Python","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python Nested Dictionary: A How-To Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"A nested dictionary is a dictionary inside of a dictionary. On Career Karma, learn how to create and use Python nested dictionaries.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Nested Dictionary: A How-To Guide\" \/>\n<meta property=\"og:description\" content=\"A nested dictionary is a dictionary inside of a dictionary. On Career Karma, learn how to create and use Python nested dictionaries.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-19T00:43:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:04:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-working-at-home-with-her-laptop-4050296.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"667\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python Nested Dictionary: A How-To Guide\",\"datePublished\":\"2020-11-19T00:43:21+00:00\",\"dateModified\":\"2023-12-01T12:04:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/\"},\"wordCount\":1197,\"commentCount\":3,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-working-at-home-with-her-laptop-4050296.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/\",\"name\":\"Python Nested Dictionary: A How-To Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-working-at-home-with-her-laptop-4050296.jpg\",\"datePublished\":\"2020-11-19T00:43:21+00:00\",\"dateModified\":\"2023-12-01T12:04:11+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"A nested dictionary is a dictionary inside of a dictionary. On Career Karma, learn how to create and use Python nested dictionaries.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-working-at-home-with-her-laptop-4050296.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-working-at-home-with-her-laptop-4050296.jpg\",\"width\":1000,\"height\":667},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\/\/careerkarma.com\/blog\/python\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python Nested Dictionary: A How-To Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Nested Dictionary: A How-To Guide | Career Karma","description":"A nested dictionary is a dictionary inside of a dictionary. On Career Karma, learn how to create and use Python nested dictionaries.","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:\/\/careerkarma.com\/blog\/python-nested-dictionary\/","og_locale":"en_US","og_type":"article","og_title":"Python Nested Dictionary: A How-To Guide","og_description":"A nested dictionary is a dictionary inside of a dictionary. On Career Karma, learn how to create and use Python nested dictionaries.","og_url":"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-11-19T00:43:21+00:00","article_modified_time":"2023-12-01T12:04:11+00:00","og_image":[{"width":1000,"height":667,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-working-at-home-with-her-laptop-4050296.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python Nested Dictionary: A How-To Guide","datePublished":"2020-11-19T00:43:21+00:00","dateModified":"2023-12-01T12:04:11+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/"},"wordCount":1197,"commentCount":3,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-working-at-home-with-her-laptop-4050296.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/","url":"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/","name":"Python Nested Dictionary: A How-To Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-working-at-home-with-her-laptop-4050296.jpg","datePublished":"2020-11-19T00:43:21+00:00","dateModified":"2023-12-01T12:04:11+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"A nested dictionary is a dictionary inside of a dictionary. On Career Karma, learn how to create and use Python nested dictionaries.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-working-at-home-with-her-laptop-4050296.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/woman-working-at-home-with-her-laptop-4050296.jpg","width":1000,"height":667},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-nested-dictionary\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/careerkarma.com\/blog\/python\/"},{"@type":"ListItem","position":3,"name":"Python Nested Dictionary: A How-To Guide"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/17565","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=17565"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/17565\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/17631"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=17565"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=17565"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=17565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}