{"id":21932,"date":"2021-01-18T11:50:17","date_gmt":"2021-01-18T19:50:17","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=21932"},"modified":"2023-12-01T04:08:11","modified_gmt":"2023-12-01T12:08:11","slug":"python-remove-key-from-a-dictionary","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-remove-key-from-a-dictionary\/","title":{"rendered":"Python Remove Key from a Dictionary: A Complete Guide"},"content":{"rendered":"\n<p><em>The Python pop() method and del keyword remove keys from a dictionary. pop() accepts the name of the key you want to remove from the dictionary as an argument. The del keyword stands on its own and refers to a specific key.<\/em><\/p>\n\n\n\n<p>Dictionaries are mutable objects. This means you can change the values dictionaries store. As a result, you can remove keys from dictionaries at any time if they are no longer needed.<\/p>\n\n\n\n<p>Suppose you have a <a href=\"https:\/\/careerkarma.com\/blog\/python-dictionary\/\">Python dictionary<\/a> that stores information about books sold in a bookstore. You may decide to remove a key that denotes if the book has been on the manager&#8217;s recommended list.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Remove Key from Dictionary<\/h2>\n\n\n\n<p>To remove a key from a dictionary in Python, use the <em>pop()<\/em> method or the \u201cdel\u201d keyword. Both methods work the same in that they remove keys from a dictionary. The pop() method accepts a key name as argument whereas &#8220;del&#8221; accepts a dictionary item after the del keyword.<\/p>\n\n\n\n<p>In this guide, we discuss how to remove a key from a Python dictionary. We\u2019ll walk through two examples so you can start removing dictionary keys quickly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Remove Key from a Dictionary Python: pop()<\/h2>\n\n\n\n<p>The Python pop() method removes an item from a dictionary.<\/p>\n\n\n\n<p>This method can also be used to remove items from a list at a particular index value. For this guide, we&#8217;ll focus on removing an item from a dictionary. Read our tutorial on the <a href=\"https:\/\/careerkarma.com\/blog\/python-pop\/\">Python list pop() guide<\/a> for more information on how to remove an item from a list.<\/p>\n\n\n\n<p>The syntax for this method is:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>dictionary.pop(key_to_remove, not_found)<\/pre><\/div>\n\n\n\n<p>The pop() method can accept either one or two parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The name of the key you want to remove (mandatory).<\/li><li>The value that should be returned if a key cannot be found (optional).<\/li><\/ul>\n\n\n\n<p>By default, <em>pop()<\/em> returns the value associated with the key that removed from a dictionary.<\/p>\n\n\n\n<p>If you only specify one parameter, the interpreter may throw a <a href=\"https:\/\/careerkarma.com\/blog\/python-keyerror\/\">Python KeyError<\/a>. This will happen if you try to remove an element from a dictionary that does not exist.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">pop() Example<\/h3>\n\n\n\n<p>We\u2019re building a program that keeps track of the shoes that are in stock at a local shoe store. Let\u2019s start by defining a <a href=\"https:\/\/careerkarma.com\/blog\/python-array\/\">Python array<\/a>. This array contains a list of shoes with which we can work:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>shoes = [\n\t{ &quot;id&quot;: 1, &quot;name&quot;: &quot;Air Force 1 Mid Casual&quot;, &quot;brand&quot;: &quot;Nike&quot;, &quot;in_stock&quot;: True },\n\t{ &quot;id&quot;: 2, &quot;name&quot;: &quot;Blazer Mid '77 Casual&quot;, &quot;brand&quot;: &quot;Nike&quot;, &quot;in_stock&quot;: True },\n\t{ &quot;id&quot;: 3, &quot;name&quot;: &quot;One Take Basketball Shoes&quot;, &quot;brand&quot;: &quot;Jordan&quot;, &quot;in_stock&quot;: False }\n]<\/pre><\/div>\n\n\n\n<p>Our list of shoes contains three dictionaries. Each dictionary contains four keys: id, name, brand, and in_stock. <em>id<\/em> is a unique identifier for a shoe. <em>name<\/em> is the name of a shoe. <em>brand<\/em> is the brand that manufactures a shoe. <em>in_stock<\/em> represents whether a shoe is in stock.<\/p>\n\n\n\n<p>The shoe store has decided to remove the \u201cin_stock\u201d key. They want to replace the key with a new value that tracks how many pairs of each shoe are in stock. To remove the \u201cin_stock\u201d key from our dictionaries, we\u2019re going to use the <em>pop()<\/em> method:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>for s in shoes:\n\tremove_key = s.pop(&quot;in_stock&quot;, None)\n\n\tif remove_key != None:\n\t\tprint(&quot;in_stock has been removed for the {} shoe.&quot;.format(s[&quot;name&quot;]))\n\telse:\n\t\tprint(&quot;No key has been removed for the {} shoe.&quot;.format(s[&quot;name&quot;]))\n\nprint(shoes)<\/pre><\/div>\n\n\n\n<p>The first parameter in the built-in function <em>pop()<\/em> is the name of the key we want to remove. Our code returns the second value if the specified key does not exist. By default, the <em>pop()<\/em> method returns the name of the removed key.<\/p>\n\n\n\n<p>In each iteration of our loop, we check if the \u201cin_stock\u201d key has been removed using an <a href=\"https:\/\/careerkarma.com\/blog\/python-if-else\/\">Python if statement<\/a>. If \u201cremove_key\u201d has a value other than None, it means our key is removed.<\/p>\n\n\n\n<p>After we remove the \u201cin_stock\u201d key our dictionaries, our code prints our new dictionary to the console. Run our code and see what happens:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>in_stock has been removed for the Air Force 1 Mid Casual shoe.\nin_stock has been removed for the Blazer Mid '77 Casual shoe.\nin_stock has been removed for the One Take Basketball Shoes shoe.\n[{'id': 1, 'name': 'Air Force 1 Mid Casual', 'brand': 'Nike'}, {'id': 2, 'name': &quot;Blazer Mid '77 Casual&quot;, 'brand': 'Nike'}, {'id': 3, 'name': 'One Take Basketball Shoes', 'brand': 'Jordan'}]<\/pre><\/div>\n\n\n\n<p>We remove the \u201cin_stock\u201d for all our shoes. Our code shows us that our keys are removed and prints out our updated dictionary to the console.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Remove Key from a Dictionary Python: del<\/h2>\n\n\n\n<p>The Python del statement deletes an object. Because key-value pairs in dictionaries are objects, you can delete them using the \u201cdel\u201d keyword.<\/p>\n\n\n\n<p>The \u201cdel\u201d keyword is used to delete a key that does exist. It raises a KeyError if a key is not present in a dictionary.<\/p>\n\n\n\n<p>Let&#8217;s take a look at the syntax for this keyword:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>del dictionary[&quot;key&quot;]<\/pre><\/div>\n\n\n\n<p>We use the indexing notation to retrieve the item from the dictionary we want to remove. &#8220;key&#8221; represents the name of the key whose key-value pair we want to remove from the dictionary.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">del Example<\/h3>\n\n\n\n<p>We\u2019re going to build a program that removes a key from an individual dictionary. This dictionary contains detailed information about a particular shoe:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>shoe = {\n\t   &quot;id&quot;: 3,\n\t   &quot;name&quot;: &quot;One Take Basketball Shoes&quot;,\n\t   &quot;brand&quot;: &quot;Jordan&quot;,\n\t   &quot;in_stock&quot;: False,\n\t   &quot;price&quot;: 100.00,\n\t   &quot;colors&quot;: [&quot;Gray&quot;],\n\t   &quot;discount&quot;: False\n}<\/pre><\/div>\n\n\n\n<p>The shoe store has decided they are not going to discount any Jordan shoes. They want to remove the \u201cdiscount\u201d key from the dictionary. We can do this using the del keyword:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>del shoe[&quot;discount&quot;]\nprint(shoe)<\/pre><\/div>\n\n\n\n<p>This code deletes the \u201cdiscount\u201d key from our list and shows us the new dictionary:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>{'id': 3, 'name': 'One Take Basketball Shoes', 'brand': 'Jordan', 'in_stock': False, 'price': 100.0, 'colors': ['Gray']}<\/pre><\/div>\n\n\n\n<p>The key \u201cdiscount\u201d is no longer in our dictionary.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python pop() vs del<\/h2>\n\n\n\n<p>There are two differences between <em>pop()<\/em> and del.<\/p>\n\n\n\n<p>First, the pop() method returns the value of the key removed from a dictionary whereas del does not return any value.<\/p>\n\n\n\n<p>Second, the del keyword returns a KeyError if a key is not in a dictionary. On the other hand, the <em>pop()<\/em> method only returns a KeyError if you do not specify a second parameter. The second parameter is the default value to be returned if a key is not present in a dictionary.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Both the <em>pop()<\/em> method and the del keyword let you remove keys from a dictionary. The <em>pop()<\/em> method is generally more useful because it is capable of returning a default value if a key is not deleted. This is handy as it helps prevent KeyErrors.<\/p>\n\n\n\n<p>Do you want to learn more about coding in Python? Read our <a href=\"https:\/\/careerkarma.com\/blog\/how-to-learn-python\/\">How to Learn Python guide<\/a>. This guide contains a list of top online courses and learning resources you can use to build your knowledge of Python.<\/p>\n","protected":false},"excerpt":{"rendered":"The Python pop() method and del keyword remove keys from a dictionary. pop() accepts the name of the key you want to remove from the dictionary as an argument. The del keyword stands on its own and refers to a specific key. Dictionaries are mutable objects. This means you can change the values dictionaries store.&hellip;","protected":false},"author":240,"featured_media":14366,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-21932","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.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python Remove Key from a Dictionary: A Complete Guide: A Complete Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"On Career Karma, learn how to use the pop() method and the del keyword to remove a key from a Python dictionary.\" \/>\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-remove-key-from-a-dictionary\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Remove Key from a Dictionary: A Complete Guide\" \/>\n<meta property=\"og:description\" content=\"On Career Karma, learn how to use the pop() method and the del keyword to remove a key from a Python dictionary.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-remove-key-from-a-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=\"2021-01-18T19:50:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:08:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/caspar-camille-rubin-fPkvU7RDmCo-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"680\" \/>\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-remove-key-from-a-dictionary\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-remove-key-from-a-dictionary\\\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python Remove Key from a Dictionary: A Complete Guide\",\"datePublished\":\"2021-01-18T19:50:17+00:00\",\"dateModified\":\"2023-12-01T12:08:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-remove-key-from-a-dictionary\\\/\"},\"wordCount\":973,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-remove-key-from-a-dictionary\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/04\\\/caspar-camille-rubin-fPkvU7RDmCo-unsplash.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-remove-key-from-a-dictionary\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-remove-key-from-a-dictionary\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-remove-key-from-a-dictionary\\\/\",\"name\":\"Python Remove Key from a Dictionary: A Complete Guide: A Complete Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-remove-key-from-a-dictionary\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-remove-key-from-a-dictionary\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/04\\\/caspar-camille-rubin-fPkvU7RDmCo-unsplash.jpg\",\"datePublished\":\"2021-01-18T19:50:17+00:00\",\"dateModified\":\"2023-12-01T12:08:11+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"On Career Karma, learn how to use the pop() method and the del keyword to remove a key from a Python dictionary.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-remove-key-from-a-dictionary\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-remove-key-from-a-dictionary\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-remove-key-from-a-dictionary\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/04\\\/caspar-camille-rubin-fPkvU7RDmCo-unsplash.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/04\\\/caspar-camille-rubin-fPkvU7RDmCo-unsplash.jpg\",\"width\":1020,\"height\":680,\"caption\":\"MacBook Pro displaying computer language codes\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-remove-key-from-a-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 Remove Key from a Dictionary: A Complete 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\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"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 Remove Key from a Dictionary: A Complete Guide: A Complete Guide | Career Karma","description":"On Career Karma, learn how to use the pop() method and the del keyword to remove a key from a Python dictionary.","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-remove-key-from-a-dictionary\/","og_locale":"en_US","og_type":"article","og_title":"Python Remove Key from a Dictionary: A Complete Guide","og_description":"On Career Karma, learn how to use the pop() method and the del keyword to remove a key from a Python dictionary.","og_url":"https:\/\/careerkarma.com\/blog\/python-remove-key-from-a-dictionary\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2021-01-18T19:50:17+00:00","article_modified_time":"2023-12-01T12:08:11+00:00","og_image":[{"width":1020,"height":680,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/caspar-camille-rubin-fPkvU7RDmCo-unsplash.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-remove-key-from-a-dictionary\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-remove-key-from-a-dictionary\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python Remove Key from a Dictionary: A Complete Guide","datePublished":"2021-01-18T19:50:17+00:00","dateModified":"2023-12-01T12:08:11+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-remove-key-from-a-dictionary\/"},"wordCount":973,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-remove-key-from-a-dictionary\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/caspar-camille-rubin-fPkvU7RDmCo-unsplash.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-remove-key-from-a-dictionary\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-remove-key-from-a-dictionary\/","url":"https:\/\/careerkarma.com\/blog\/python-remove-key-from-a-dictionary\/","name":"Python Remove Key from a Dictionary: A Complete Guide: A Complete Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-remove-key-from-a-dictionary\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-remove-key-from-a-dictionary\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/caspar-camille-rubin-fPkvU7RDmCo-unsplash.jpg","datePublished":"2021-01-18T19:50:17+00:00","dateModified":"2023-12-01T12:08:11+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"On Career Karma, learn how to use the pop() method and the del keyword to remove a key from a Python dictionary.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-remove-key-from-a-dictionary\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-remove-key-from-a-dictionary\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-remove-key-from-a-dictionary\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/caspar-camille-rubin-fPkvU7RDmCo-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/caspar-camille-rubin-fPkvU7RDmCo-unsplash.jpg","width":1020,"height":680,"caption":"MacBook Pro displaying computer language codes"},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-remove-key-from-a-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 Remove Key from a Dictionary: A Complete 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\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","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\/21932","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=21932"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/21932\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/14366"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=21932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=21932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=21932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}