{"id":13196,"date":"2020-12-03T14:11:00","date_gmt":"2020-12-03T22:11:00","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=13196"},"modified":"2023-12-01T04:05:36","modified_gmt":"2023-12-01T12:05:36","slug":"python-dictionary-get","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/","title":{"rendered":"Python Dictionary Get: Step-By-Step Guide"},"content":{"rendered":"\n<p><em>The Python dictionary get() method returns the value associated with a specific key. get() accepts two arguments: the key for which you want to search and a default value that is returned if the key is not found.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Retrieving a value for a specified key in a dictionary is a common operation when you\u2019re working with dictionaries. For instance, you may be a tea shop owner and want to retrieve how many orders you had for white tea.<\/p>\n\n\n\n<p>That\u2019s where the Python dictionary get\u2014<em>dict.get()<\/em>\u2014method comes in: it returns the value for a specified key in a dictionary.&nbsp;<\/p>\n\n\n\n<p>This method will only return a value if the specified key is present in the dictionary, otherwise it will return <em>None<\/em>.<\/p>\n\n\n\n<p>In this tutorial, we will explore Python\u2019s built-in <em>dict.get()<\/em> method and how you can use it to retrieve specific values from Python dictionaries. In addition, we\u2019ll walk through examples of the <em>dict.get()<\/em> method in real programs to explain how it works in more depth. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Dictionary Refresher<\/h2>\n\n\n\n<p><a href=\"https:\/\/careerkarma.com\/blog\/python-dictionary\/\">Python dictionaries<\/a> map keys to values and create key-value pairs that can be used to store data. Dictionaries are often used to hold related data. For instance, a dictionary could act as the record of a student at a school or information about a book in a library.&nbsp;I want to give the writers direct feedback so that they can improve instead of just fixing errors.<\/p>\n\n\n\n<p>Here\u2019s an example of a dictionary in Python that holds information about a specific tea sold in a tea shop:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>black_tea = {\n\t'supplier': 'Twinings',\n\t'name': 'English Breakfast'\n\t'boxes_in_stock': 12,\n\t'loose_leaf': True\n}<\/pre><\/div>\n\n\n\n<p>The words to the left of the colons are dictionary keys, which in the above example are: <em>supplier<\/em>, <em>name<\/em>, <em>boxes_in_stock<\/em>, and <em>loose_leaf<\/em>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Dictionary get() Method<\/h2>\n\n\n\n<p>The Python dictionary get() method retrieves a value mapped to a particular key. get() will return None if the key is not found, or a default value if one is specified.<\/p>\n\n\n\n<p>The syntax for the <em>dict.get()<\/em> method in Python is as follows:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>dictionary_name.get(name, value)<\/pre><\/div>\n\n\n\n<p>The <em>dict.get()<\/em> method accepts two parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>name<\/strong> is the name of the key whose value you want to return. This parameter is <em>required<\/em>.<\/li><li><strong>value<\/strong> is the value to return if the specified key does not exist. This defaults to <em>None<\/em>. This parameter is <em>optional<\/em>.<\/li><\/ul>\n\n\n\n<p>You can retrieve items from a dictionary using indexing syntax. As we&#8217;ll discuss later in this guide, this can sometimes be counterintuitive.<\/p>\n\n\n\n<p>Most beginners learn indexing first. But, once you know how to use get() you&#8217;ll probably find yourself using it more often than dictionary indexing to retrieve a value.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Get Values from Dictionary in Python: Example<\/h2>\n\n\n\n<p>Let\u2019s walk through an example to demonstrate the <em>dict.get()<\/em> method in action. Say that we are operating a tea house, and we want to see how many people ordered <em>matcha_green_tea<\/em> last month.<\/p>\n\n\n\n<p>This data is part of a dictionary that stores the names of teas as <strong>keys.<\/strong> The number of people who ordered specific teas are stored as <strong>values<\/strong>.<\/p>\n\n\n\n<p>We could use the following code to retrieve how many people ordered <em>matcha_green_tea<\/em>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>teas = {\n\t'english_breakfast': 104,\n\t'matcha_green_tea': 26,\n\t'green_tea': 29,\n\t'decaf_english_breakfast': 51,\n\t'assam': 48\n}\n\nmatcha = teas.get('matcha_green_tea')\n\nprint(matcha)<\/pre><\/div>\n\n\n\n<p>Our code returns: <em>26<\/em>.<\/p>\n\n\n\n<p>At the start of our code, we define a <a href=\"https:\/\/careerkarma.com\/blog\/python-variables\/\">Python variable<\/a> called <em>teas<\/em>. This dictionary stores information about tea orders in our tea house.<\/p>\n\n\n\n<p>Then, we use the <em>dict.get()<\/em> method on our <em>teas<\/em> dictionary to retrieve the value associated with the <em>matcha_green_tea<\/em> key. Finally, we print out the value to the console using a <a href=\"https:\/\/careerkarma.com\/blog\/python-print-without-new-line\/\">Python print() statement<\/a>.<\/p>\n\n\n\n<p>Let\u2019s consider another example. Let\u2019s say that we have a dictionary for each tea that we sell. These dictionaries contain information about their respective teas, including:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Who the supplier is.<\/li><li>What we name the tea.<\/li><li>How many boxes we have in stock.<\/li><li>Whether it is loose-leaf.<\/li><\/ul>\n\n\n\n<p>The following is our dictionary for the black tea we sell:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>black_tea = {\n\t'supplier': 'Twinings',\n\t'name': 'English Breakfast'\n\t'boxes_in_stock': 12,\n\t'loose_leaf': True\n}<\/pre><\/div>\n\n\n\n<p>Suppose we want to find out whether our black tea is stored as a loose-leaf tea. We could do so using this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>get_loose_leaf = black_tea.get('loose_leaf')\n\nprint(get_loose_leaf)<\/pre><\/div>\n\n\n\n<p>Our code returns a <a href=\"https:\/\/careerkarma.com\/blog\/python-boolean\/\">Python boolean value<\/a>: <em>True<\/em>.<\/p>\n\n\n\n<p>We use the <em>dict.get()<\/em> method to retrieve the value of <em>loose_leaf<\/em> in the <em>black_tea<\/em> dictionary. The fact that our code returns <em>True<\/em> tells us that our black tea is stored as a loose-leaf tea. We would receive a None value if our tea did not exist in the dictionary.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Dictionary get(): Default Value<\/h2>\n\n\n\n<p>The <em>dict.get()<\/em> method accepts an optional second parameter. This parameter specifies the value that should be returned if a key cannot be found within a dictionary. This lets you change the default response of None if a value is not found.<\/p>\n\n\n\n<p>So, let\u2019s say that we want to retrieve <em>taste_notes<\/em> from a dictionary that stores information about the black tea our tea house stocks. We only just hired our tea taster tasked with writing those descriptions, so they don\u2019t exist for all teas yet. Tasting notes do not exist for our black tea.<\/p>\n\n\n\n<p>To avoid our program returning <em>None<\/em>, we want our code to return a notification message. This message should inform us that the taste notes are not available for that tea yet. <\/p>\n\n\n\n<p>The below program retrieves <em>taste_notes<\/em> from a dictionary containing information about our black tea. Our program returns a message if the taste notes are not available:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>black_tea = {\n\t'supplier': 'Twinings',\n\t'name': 'English Breakfast'\n\t'boxes_in_stock': 12,\n\t'loose_leaf': True\n}\n\nget_loose_leaf = black_tea.get('taste_notes', 'Taste notes are not available for this tea yet.')\n\nprint(get_loose_leaf)<\/pre><\/div>\n\n\n\n<p>Our <em>black_tea<\/em> dictionary does not contain a value for the key <em>taste_notes<\/em>, so our program returns the following message:<\/p>\n\n\n\n<p>Taste notes are not available for this tea yet.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Dictionary get() vs. dict[key]<\/h2>\n\n\n\n<p>One common method used to access a value in a dictionary is to reference its value using the <em>dict[key]<\/em> syntax.<\/p>\n\n\n\n<p>The difference between the <em>dict[key]<\/em> syntax and <em>dict.get()<\/em> is that if a key is not found using the <em>dict[key]<\/em> syntax, a KeyError is raised. If you use <em>dict.get()<\/em> and a key is not found, the code will return <em>None<\/em> (or a custom value, if you specify one).<\/p>\n\n\n\n<p>Here\u2019s what happens if we try to use the <em>dict[key]<\/em> syntax to retrieve <em>taste_notes<\/em> from a dictionary that lacks that key:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>black_tea = {\n\t'supplier': 'Twinings',\n\t'name': 'English Breakfast'\n\t'boxes_in_stock': 12,\n\t'loose_leaf': True\n}\n\nprint(black_tea['taste_notes'])<\/pre><\/div>\n\n\n\n<p>Because <em>taste_notes<\/em> is not present in our <em>black_tea<\/em> dictionary, our code returns the following error:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>KeyError: 'taste_notes'<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The <em>dict.get()<\/em> method is used in Python to retrieve a value from a dictionary. <em>dict.get()<\/em> returns <em>None<\/em> by default if the key you specify cannot be found. With this method, you can specify a second parameter that will return a custom default value if a key is not found.<\/p>\n\n\n\n<p>You can also use the <em>dict[key]<\/em> syntax to retrieve a value from a dictionary. If you use the <em>dict[key]<\/em> syntax and the program cannot find the key you specify, the code will return a KeyError. Because this syntax returns an error, using the <em>dict.get()<\/em> method is often more appropriate.<\/p>\n\n\n\n<p>Now you\u2019re ready to start retrieving values from a Python dictionary using <em>dict.get()<\/em> like a pro! For guidance on Python courses and learning resources, check out our <a href=\"https:\/\/careerkarma.com\/blog\/how-to-learn-python\/\">How to Learn Python guide<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"The Python dictionary get() method returns the value associated with a specific key. get() accepts two arguments: the key for which you want to search and a default value that is returned if the key is not found. Retrieving a value for a specified key in a dictionary is a common operation when you\u2019re working&hellip;","protected":false},"author":240,"featured_media":13198,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-13196","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 Dictionary Get: Step-By-Step Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"The dict.get method allows Python coders to retrieve a value associated with a specified key in a dictionary. Learn how to use the dict.get method in your code on Career Karma.\" \/>\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-dictionary-get\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Dictionary Get: Step-By-Step Guide\" \/>\n<meta property=\"og:description\" content=\"The dict.get method allows Python coders to retrieve a value associated with a specified key in a dictionary. Learn how to use the dict.get method in your code on Career Karma.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/\" \/>\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-12-03T22:11:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:05:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/photography-of-laptop-computer-camera-smartphone-headphones-705164.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"662\" \/>\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=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python Dictionary Get: Step-By-Step Guide\",\"datePublished\":\"2020-12-03T22:11:00+00:00\",\"dateModified\":\"2023-12-01T12:05:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/\"},\"wordCount\":1174,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/photography-of-laptop-computer-camera-smartphone-headphones-705164.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/\",\"name\":\"Python Dictionary Get: Step-By-Step Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/photography-of-laptop-computer-camera-smartphone-headphones-705164.jpg\",\"datePublished\":\"2020-12-03T22:11:00+00:00\",\"dateModified\":\"2023-12-01T12:05:36+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"The dict.get method allows Python coders to retrieve a value associated with a specified key in a dictionary. Learn how to use the dict.get method in your code on Career Karma.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/photography-of-laptop-computer-camera-smartphone-headphones-705164.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/photography-of-laptop-computer-camera-smartphone-headphones-705164.jpg\",\"width\":1020,\"height\":662,\"caption\":\"Python Dictionary Get\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/#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 Dictionary Get: Step-By-Step 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 Dictionary Get: Step-By-Step Guide | Career Karma","description":"The dict.get method allows Python coders to retrieve a value associated with a specified key in a dictionary. Learn how to use the dict.get method in your code on Career Karma.","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-dictionary-get\/","og_locale":"en_US","og_type":"article","og_title":"Python Dictionary Get: Step-By-Step Guide","og_description":"The dict.get method allows Python coders to retrieve a value associated with a specified key in a dictionary. Learn how to use the dict.get method in your code on Career Karma.","og_url":"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-12-03T22:11:00+00:00","article_modified_time":"2023-12-01T12:05:36+00:00","og_image":[{"width":1020,"height":662,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/photography-of-laptop-computer-camera-smartphone-headphones-705164.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":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python Dictionary Get: Step-By-Step Guide","datePublished":"2020-12-03T22:11:00+00:00","dateModified":"2023-12-01T12:05:36+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/"},"wordCount":1174,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/photography-of-laptop-computer-camera-smartphone-headphones-705164.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-dictionary-get\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/","url":"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/","name":"Python Dictionary Get: Step-By-Step Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/photography-of-laptop-computer-camera-smartphone-headphones-705164.jpg","datePublished":"2020-12-03T22:11:00+00:00","dateModified":"2023-12-01T12:05:36+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"The dict.get method allows Python coders to retrieve a value associated with a specified key in a dictionary. Learn how to use the dict.get method in your code on Career Karma.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-dictionary-get\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/photography-of-laptop-computer-camera-smartphone-headphones-705164.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/photography-of-laptop-computer-camera-smartphone-headphones-705164.jpg","width":1020,"height":662,"caption":"Python Dictionary Get"},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-dictionary-get\/#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 Dictionary Get: Step-By-Step 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\/13196","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=13196"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/13196\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/13198"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=13196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=13196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=13196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}