{"id":50,"date":"2023-03-30T04:56:55","date_gmt":"2023-03-30T04:56:55","guid":{"rendered":"http:\/\/www.programminginpython.com\/2023\/03\/30\/python-dictionary-and-its-operations\/"},"modified":"2023-04-23T12:10:57","modified_gmt":"2023-04-23T12:10:57","slug":"python-dictionary-operations","status":"publish","type":"post","link":"https:\/\/www.programminginpython.com\/python-dictionary-operations\/","title":{"rendered":"Python Dictionary and its operations"},"content":{"rendered":"<p>Hello everyone, Welcome back to <a href=\"https:\/\/programminginpython.com\" target=\"_blank\" rel=\"noopener noreferrer\">proramminginpython.com<\/a>. Here in this post am going to introduce you to one of the popular Python data types \u2013 <strong>Dictionary<\/strong>. <a href=\"https:\/\/programminginpython.com\/python-lists-add-append-modify-remove-slice\/\" target=\"_blank\" rel=\"noopener noreferrer\">Lists<\/a> and <a href=\"https:\/\/programminginpython.com\/python-tuple-add-remove-slice-concatenate-reverse\/\" target=\"_blank\" rel=\"noopener noreferrer\">Tuples<\/a> are some of the other data types. Dictionaries are indexed by keys and can be of any immutable type. These are unordered key-value pairs with unique keys.<\/p>\n<p>A dictionary can be created simply by writing curly braces <code>{}<\/code>\u00a0an example dictionary will look like <code>{'key1': 'value1', 'key2': 'value2'}<\/code><\/p>\n<p>Now let\u2019s go through the operations that can be performed on dictionaries.<\/p>\n<div class=\"yrc-shell-cover yrc-single\" data-yrc-uid=\"69e0d68be1935\" data-yrc-channel=\"{&quot;meta&quot;:{&quot;user&quot;:&quot;Programming In Python&quot;,&quot;channel&quot;:&quot;UCLBlXUMLYLxopRljNdLXOeQ&quot;,&quot;key&quot;:&quot;yrc_1683138754&quot;,&quot;apikey&quot;:&quot;AIzaSyC3vU6rFyzsO0shrRsAWmjuSiuWYTQhafc&quot;,&quot;cache&quot;:&quot;1440&quot;,&quot;channel_uploads&quot;:&quot;UULBlXUMLYLxopRljNdLXOeQ&quot;,&quot;onlyonce&quot;:&quot;&quot;,&quot;tag&quot;:&quot;&quot;,&quot;per_page&quot;:&quot;24&quot;,&quot;maxv&quot;:&quot;0&quot;,&quot;consent&quot;:{&quot;ask&quot;:&quot;&quot;,&quot;url&quot;:&quot;&quot;},&quot;ads&quot;:&quot;1&quot;,&quot;uid&quot;:&quot;69e0d68be1935&quot;,&quot;nocookie&quot;:&quot;&quot;,&quot;single&quot;:true},&quot;style&quot;:{&quot;colors&quot;:{&quot;item&quot;:{&quot;background&quot;:&quot;inherit&quot;},&quot;button&quot;:{&quot;background&quot;:&quot;#333&quot;,&quot;color&quot;:&quot;#fff&quot;},&quot;color&quot;:{&quot;text&quot;:&quot;#fff&quot;,&quot;link&quot;:&quot;inherit&quot;,&quot;menu&quot;:&quot;#000&quot;,&quot;meta&quot;:&quot;inherit&quot;}},&quot;theme&quot;:{&quot;videos&quot;:{&quot;style&quot;:&quot;__grid&quot;,&quot;thumb&quot;:[&quot;large&quot;,&quot;open&quot;],&quot;desc&quot;:&quot;&quot;,&quot;carousel&quot;:{&quot;thumbs&quot;:&quot;4&quot;,&quot;thumbs_to_slide&quot;:&quot;2&quot;,&quot;spacing&quot;:&quot;10&quot;},&quot;carousel_nav&quot;:{&quot;modifier&quot;:&quot;__sides&quot;,&quot;position&quot;:&quot;left-none&quot;,&quot;location&quot;:&quot;prepend&quot;,&quot;background&quot;:&quot;#fff&quot;,&quot;color&quot;:&quot;#000&quot;,&quot;font_size&quot;:&quot;2&quot;,&quot;border_radius&quot;:&quot;0&quot;}},&quot;a&quot;:&quot;1&quot;},&quot;fit&quot;:&quot;false&quot;,&quot;playlists&quot;:&quot;true&quot;,&quot;uploads&quot;:&quot;true&quot;,&quot;player_mode&quot;:&quot;1&quot;,&quot;truncate&quot;:&quot;&quot;,&quot;banner&quot;:&quot;true&quot;,&quot;thumb_margin&quot;:&quot;8&quot;,&quot;play_icon&quot;:&quot;hover&quot;,&quot;youtube_play_icon&quot;:&quot;&quot;,&quot;thumb_image_size&quot;:&quot;medium&quot;,&quot;default_tab&quot;:&quot;uploads&quot;,&quot;sticky&quot;:{&quot;enable&quot;:&quot;&quot;,&quot;width&quot;:&quot;400&quot;,&quot;position&quot;:&quot;bottom-right&quot;,&quot;only_above&quot;:&quot;768&quot;,&quot;margin&quot;:&quot;12&quot;},&quot;player&quot;:{&quot;show_desc&quot;:&quot;&quot;,&quot;show_meta&quot;:&quot;&quot;},&quot;menu&quot;:&quot;1&quot;,&quot;rating_style&quot;:&quot;NaN&quot;,&quot;rtl&quot;:false}}\" data-yrc-setup=\"\"><\/div>\r\n\t\t\t<script data-cfasync=\"false\" type=\"text\/javascript\">\r\n\t\t\t\tif( !window.YRC ) var YRC = {Data:{}};\r\n\t\t\t\tYRC.Data[\"69e0d68be1935\"] = {\"video\":\"hyB9_y4yGF8\"};\r\n\t\t\t\t(function(){\r\n\t\t\t\t\tif(!YRC.loaded){\r\n\t\t\t\t\t    YRC.loaded = true;\r\n\t\t\t\t\t\tfunction YRC_Loader(){\r\n\t\t\t\t\t\t\t\/\/YRC.loaded = true;\r\n\t\t\t\t\t\t\tYRC.is_pro = false;\r\n\t\t\t\t\t\t\tYRC.is_pb = false;\r\n\t\t\t\t\t\t\tYRC.lang = {\"form\":{\"Videos\":\"Videos\",\"Playlists\":\"Playlists\",\"Search\":\"Search\",\"Loading\":\"Loading\",\"more\":\"more\",\"Nothing_found\":\"Nothing found\",\"Prev\":\"Previous\",\"Next\":\"Next\",\"consent_statement\":\"Allow cookies?\",\"consent_button\":\"Allow\",\"consent_privacy_policy\":\"Privacy policy\"},\"fui\":{\"sort_by\":\"Sort by\",\"relevant\":\"Relevant\",\"latest\":\"Latest\",\"liked\":\"Liked\",\"title\":\"Title\",\"views\":\"Views\",\"duration\":\"Duration\",\"any\":\"Any\",\"_short\":\"Short\",\"medium\":\"Medium\",\"_long\":\"Long\",\"uploaded\":\"Uploaded\",\"all_time\":\"All time\",\"live_now\":\"Live Now\",\"today\":\"Today\",\"ago\":\"ago\",\"last\":\"Last\",\"day\":\"day\",\"days\":\"days\",\"week\":\"week\",\"weeks\":\"weeks\",\"month\":\"month\",\"months\":\"months\",\"year\":\"year\",\"years\":\"years\",\"older\":\"Older\",\"show_more\":\"Show More\",\"show_less\":\"Show Less\",\"reply\":\"REPLY\",\"view_replies\":\"View replies\",\"write_comment\":\"Write comment...\",\"billion\":\"B\",\"million\":\"M\",\"thousand\":\"K\",\"max_plain_number\":1000,\"wplocale\":\"en_US\"}};\r\n\t\t\t\t\t\t\tYRC.is_admin = false;\r\n\t\t\t\t\t\t\tvar script = document.createElement(\"script\");\r\n\t\t\t\t\t\t\t\tscript.setAttribute(\"data-cfasync\", \"false\");\r\n\t\t\t\t\t\t\t\tscript.setAttribute(\"type\", \"text\/javascript\");\r\n\t\t\t\t\t\t\t\tscript.src = \"https:\/\/www.programminginpython.com\/wp-content\/plugins\/yourchannel\/js\/yrc.js?1.2.9\";\r\n\t\t\t\t\t\t\t\tscript.id = \"yrc-script\";\r\n\t\t\t\t\t\t\t\tdocument.querySelector(\"head\").appendChild(script);\r\n\t\t\t\t\t\t\tvar style = document.createElement(\"link\");\r\n\t\t\t\t\t\t\t\tstyle.rel = \"stylesheet\";\r\n\t\t\t\t\t\t\t\tstyle.href = \"https:\/\/www.programminginpython.com\/wp-content\/plugins\/yourchannel\/css\/style.css?1.2.9\";\r\n\t\t\t\t\t\t\t\tstyle.type = \"text\/css\";\r\n\t\t\t\t\t\t\t\tdocument.querySelector(\"head\").appendChild(style);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif(window.jQuery){YRC_Loader();}else { var yrctimer2324 = window.setInterval(function(){\r\n\t\t\t\t\t\t\tif(window.jQuery){YRC_Loader(); window.clearInterval(yrctimer2324); }\r\n\t\t\t\t\t\t}, 250);}\r\n\t\t\t\t\t} else {if(YRC.EM)YRC.EM.trigger(\"yrc.newchannel\");}\r\n\t\t\t\t}());<\/script>\n<p style=\"text-align: center;\"><strong>You can also watch the video on YouTube <\/strong><a href=\"https:\/\/www.youtube.com\/watch?v=hyB9_y4yGF8\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>here<\/strong><\/a><\/p>\n<p>&nbsp;<\/p>\n<p class=\"extra_btn_para\"><span class=\"wdg\"> <a href=\"https:\/\/github.com\/avinashn\/programminginpython.com\/blob\/master\/dictionaryOperations.py\" target=\"_blank\" rel=\"noopener noreferrer\"> <i class=\"fa fa-github fa-lg\"><\/i> Program on GitHub<\/a><\/span><\/p>\n<div class=\"visualize_iframe\">\n<h4 class=\"post_h4\">Python Dictionary Operations \u2013 Code Visualization<\/h4>\n<p><iframe src=\"https:\/\/pythontutor.com\/iframe-embed.html#code=__author__%20%3D%20'Avinash'%0A%0A%23%20add%20elements%20to%20dictionary%0Amy_info%20%3D%20%7B%0A%20%20%20%20'Name'%3A%20'Avinash',%0A%20%20%20%20'Age'%3A%2023,%0A%20%20%20%20'Gender'%3A%20'Male',%0A%20%20%20%20'Location'%3A%20'India',%0A%20%20%20%20'Website'%3A%20'programminginpython.com'%0A%20%20%20%20%7D%0A%0A%23%20print%20dictionary%0Aprint%28my_info%29%0A%0A%23%20print%20value%20of%20a%20key%0Aprint%28my_info%5B'Name'%5D%29%0A%0A%23%20modify%20elements%20in%20dictionary%0Amy_info%5B'Age'%5D%20%3D%2024%0Aprint%28my_info%29%0A%0A%23%20length%20of%20dictionary%0Aprint%28len%28my_info%29%29%0A%0A%23%20delete%20a%20particular%20key%0Adel%20my_info%5B'Website'%5D%0Aprint%28my_info%29%0A%0A%23%20removes%20all%20elements%20in%20dictionary%0Amy_info.clear%28%29%0Aprint%28my_info%29%0A%0A%23%20delete%20entire%20dictionary%0Adel%20my_info%0A&amp;codeDivHeight=400&amp;codeDivWidth=350&amp;cumulative=false&amp;curInstr=0&amp;heapPrimitives=false&amp;origin=opt-frontend.js&amp;py=3&amp;rawInputLstJSON=%5B%5D&amp;textReferences=false\" width=\"800\" height=\"500\" frameborder=\"0\"> <\/iframe><\/p>\n<\/div>\n<h4 class=\"post_h4\">Create Dictionary<\/h4>\n<p>I will create a dictionary named <code>my_info<\/code>and add some key-value pairs to it.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\"># add elements to dictionary\r\nmy_info = {\r\n    'Name': 'Avinash',\r\n    'Age': 23,\r\n    'Gender': 'Male',\r\n    'Location': 'India',\r\n    'Website': 'programminginpython.com'\r\n    }<\/pre>\n<p>and print it.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># print dictionary\r\nprint(my_info)<\/pre>\n<figure id=\"attachment_707\" class=\"wp-caption aligncenter\" style=\"width: 844px;\" aria-describedby=\"caption-attachment-707\"><img decoding=\"async\" class=\"aligncenter wp-image-651 size-full lazyload\" data-src=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python_dict_1.png\" alt=\"Python Dictionary and its operations\" width=\"844\" height=\"145\" data-srcset=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python_dict_1.png 844w, https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python_dict_1.png 300w, https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python_dict_1.png 768w\" data-sizes=\"(max-width: 640px) 100vw, 640px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 844px; --smush-placeholder-aspect-ratio: 844\/145;\" \/><\/figure>\n<p class=\"extra_btn_para\"><span class=\"wdg\"> <a href=\"https:\/\/github.com\/avinashn\/programminginpython.com\/blob\/master\/dictionaryOperations.py\" target=\"_blank\" rel=\"noopener noreferrer\"> <i class=\"fa fa-github fa-lg\"><\/i> Program on GitHub<\/a><\/span><\/p>\n<h4 class=\"post_h4\">Accessing Values<\/h4>\n<p>Now I can access the elements in the dictionary by their key, here I will print the value of the key <code>'Name'<\/code>.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">my_info = {\r\n    'Name': 'Avinash',\r\n    'Age': 23,\r\n    'Gender': 'Male',\r\n    'Location': 'India',\r\n    'Website': 'programminginpython.com'\r\n    }\r\n\r\n# print value of a key\r\nprint(my_info['Name'])<\/pre>\n<figure id=\"attachment_708\" class=\"wp-caption aligncenter\" style=\"width: 818px;\" aria-describedby=\"caption-attachment-708\">\n<p><figure id=\"attachment_652\" aria-describedby=\"caption-attachment-652\" style=\"width: 818px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-652 lazyload\" data-src=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python_dictionary_2.png\" alt=\"Python Dictionary and its operations\" width=\"818\" height=\"151\" data-srcset=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python_dictionary_2.png 818w, https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python_dictionary_2.png 300w, https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python_dictionary_2.png 768w\" data-sizes=\"(max-width: 640px) 100vw, 640px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 818px; --smush-placeholder-aspect-ratio: 818\/151;\" \/><figcaption id=\"caption-attachment-652\" class=\"wp-caption-text\">Python Dictionary and its operations<\/figcaption><\/figure><\/figure>\n<h4 class=\"post_h4\">Modifying values<\/h4>\n<p>I can also modify the existing elements in the dictionary, here I will modify the value of key <code>'Age'<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">my_info = {\r\n    'Name': 'Avinash',\r\n    'Age': 23,\r\n    'Gender': 'Male',\r\n    'Location': 'India',\r\n    'Website': 'programminginpython.com'\r\n    }\r\n\r\n# modify elements in dictionary\r\nmy_info['Age'] = 24\r\nprint(my_info)<\/pre>\n<figure id=\"attachment_710\" class=\"wp-caption aligncenter\" style=\"width: 872px;\" aria-describedby=\"caption-attachment-710\">\n<p><figure id=\"attachment_653\" aria-describedby=\"caption-attachment-653\" style=\"width: 872px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-653 lazyload\" data-src=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python_dictionary_3.png\" alt=\"Python Dictionary and its operations\" width=\"872\" height=\"110\" data-srcset=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python_dictionary_3.png 872w, https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python_dictionary_3.png 300w, https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python_dictionary_3.png 768w\" data-sizes=\"(max-width: 640px) 100vw, 640px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 872px; --smush-placeholder-aspect-ratio: 872\/110;\" \/><figcaption id=\"caption-attachment-653\" class=\"wp-caption-text\">Python Dictionary and its operations<\/figcaption><\/figure><\/figure>\n<p class=\"extra_btn_para\"><span class=\"wdg\"> <a href=\"https:\/\/github.com\/avinashn\/programminginpython.com\/blob\/master\/dictionaryOperations.py\" target=\"_blank\" rel=\"noopener noreferrer\"> <i class=\"fa fa-github fa-lg\"><\/i> Program on GitHub<\/a><\/span><\/p>\n<h4 class=\"post_h4\">Length of dictionary<\/h4>\n<p>I can also find the length of the dictionary, using the built-in method <code>len()<\/code> which gives the total number of items in the dictionary.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">my_info = {\r\n    'Name': 'Avinash',\r\n    'Age': 23,\r\n    'Gender': 'Male',\r\n    'Location': 'India',\r\n    'Website': 'programminginpython.com'\r\n    }\r\n\r\n# length of dictionary\r\nprint(len(my_info))<\/pre>\n<figure id=\"attachment_711\" class=\"wp-caption aligncenter\" style=\"width: 819px;\" aria-describedby=\"caption-attachment-711\">\n<p><figure id=\"attachment_654\" aria-describedby=\"caption-attachment-654\" style=\"width: 819px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-654 lazyload\" data-src=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python_dictionary_4.png\" alt=\"Python Dictionary and its operations\" width=\"819\" height=\"116\" data-srcset=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python_dictionary_4.png 819w, https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python_dictionary_4.png 300w, https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python_dictionary_4.png 768w\" data-sizes=\"(max-width: 640px) 100vw, 640px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 819px; --smush-placeholder-aspect-ratio: 819\/116;\" \/><figcaption id=\"caption-attachment-654\" class=\"wp-caption-text\">Python Dictionary and its operations<\/figcaption><\/figure><\/figure>\n<h4 class=\"post_h4\">Delete elements<\/h4>\n<p>I can also delete a particular key from a dictionary, here I will delete key <code>'Website'<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">my_info = {\r\n    'Name': 'Avinash',\r\n    'Age': 23,\r\n    'Gender': 'Male',\r\n    'Location': 'India',\r\n    'Website': 'programminginpython.com'\r\n    }<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\"># delete a particular key \r\ndel my_info['Website'] \r\nprint(my_info)<\/pre>\n<p>Similarly, I can remove all the elements using a function called <code>clear()<\/code> which empties all the elements in the dictionary<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\"># removes all elements in dictionary \r\nmy_info.clear()<\/pre>\n<p>I can also delete the entire dictionary,<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\"># delete entire dictionary \r\ndel my_info<\/pre>\n<p>These are some of the operations that can be performed on dictionaries.<\/p>\n<p class=\"extra_btn_para\"><span class=\"wdg\"> <a href=\"https:\/\/github.com\/avinashn\/programminginpython.com\/blob\/master\/dictionaryOperations.py\" target=\"_blank\" rel=\"noopener noreferrer\"> <i class=\"fa fa-github fa-lg\"><\/i> Program on GitHub<\/a><\/span><\/p>\n<p>The complete code for the above snippets,<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">__author__ = 'Avinash'\r\n\r\n# add elements to dictionary\r\nmy_info = {\r\n    'Name': 'Avinash',\r\n    'Age': 23,\r\n    'Gender': 'Male',\r\n    'Location': 'India',\r\n    'Website': 'programminginpython.com'\r\n    }\r\n\r\n# print dictionary\r\nprint(my_info)\r\n\r\n# print value of a key\r\nprint(my_info['Name'])\r\n\r\n# modify elements in dictionary\r\nmy_info['Age'] = 24\r\nprint(my_info)\r\n\r\n# length of dictionary\r\nprint(len(my_info))\r\n\r\n# delete a particular key\r\ndel my_info['Website']\r\nprint(my_info)\r\n\r\n# removes all elements in dictionary\r\nmy_info.clear()\r\nprint(my_info)\r\n\r\n# delete entire dictionary\r\ndel my_info<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello everyone, Welcome back to proramminginpython.com. Here in this post am going to introduce you to one of the popular python data type &#8211; Dictionary. Lists and Tuples are some of the other data types. &hellip;<\/p>\n","protected":false},"author":1,"featured_media":264,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,10,14],"tags":[47,65,118],"class_list":["post-50","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-basic-programs","category-data-structures","category-dictionaries","tag-data-structures","tag-dictionary","tag-dictionary-operations"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python Dictionary and its operations - Programming In Python<\/title>\n<meta name=\"description\" content=\"A Python Program demonstrating a Python Dictionary and its operations like adding, modifying and deleting elements 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:\/\/www.programminginpython.com\/python-dictionary-operations\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Dictionary and its operations - Programming In Python\" \/>\n<meta property=\"og:description\" content=\"A Python Program demonstrating a Python Dictionary and its operations like adding, modifying and deleting elements from a Python Dictionary.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.programminginpython.com\/python-dictionary-operations\/\" \/>\n<meta property=\"og:site_name\" content=\"Programming In Python\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/programminginpython\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-30T04:56:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-23T12:10:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python-Dictionaries_Fb.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"AVINASH NETHALA\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@python_pip\" \/>\n<meta name=\"twitter:site\" content=\"@python_pip\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"AVINASH NETHALA\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Dictionary and its operations - Programming In Python","description":"A Python Program demonstrating a Python Dictionary and its operations like adding, modifying and deleting elements 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:\/\/www.programminginpython.com\/python-dictionary-operations\/","og_locale":"en_US","og_type":"article","og_title":"Python Dictionary and its operations - Programming In Python","og_description":"A Python Program demonstrating a Python Dictionary and its operations like adding, modifying and deleting elements from a Python Dictionary.","og_url":"https:\/\/www.programminginpython.com\/python-dictionary-operations\/","og_site_name":"Programming In Python","article_publisher":"https:\/\/www.facebook.com\/programminginpython","article_published_time":"2023-03-30T04:56:55+00:00","article_modified_time":"2023-04-23T12:10:57+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python-Dictionaries_Fb.png","type":"image\/png"}],"author":"AVINASH NETHALA","twitter_card":"summary_large_image","twitter_creator":"@python_pip","twitter_site":"@python_pip","twitter_misc":{"Written by":"AVINASH NETHALA","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.programminginpython.com\/python-dictionary-operations\/#article","isPartOf":{"@id":"https:\/\/www.programminginpython.com\/python-dictionary-operations\/"},"author":{"name":"AVINASH NETHALA","@id":"https:\/\/www.programminginpython.com\/#\/schema\/person\/9a3c14fe46d422ebf783ee61de1e788c"},"headline":"Python Dictionary and its operations","datePublished":"2023-03-30T04:56:55+00:00","dateModified":"2023-04-23T12:10:57+00:00","mainEntityOfPage":{"@id":"https:\/\/www.programminginpython.com\/python-dictionary-operations\/"},"wordCount":307,"commentCount":0,"publisher":{"@id":"https:\/\/www.programminginpython.com\/#organization"},"image":{"@id":"https:\/\/www.programminginpython.com\/python-dictionary-operations\/#primaryimage"},"thumbnailUrl":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python-Dictionaries_Wp1.png","keywords":["data structures","dictionary","dictionary operations"],"articleSection":["Basic Programs","Data Structures","Dictionaries"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.programminginpython.com\/python-dictionary-operations\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.programminginpython.com\/python-dictionary-operations\/","url":"https:\/\/www.programminginpython.com\/python-dictionary-operations\/","name":"Python Dictionary and its operations - Programming In Python","isPartOf":{"@id":"https:\/\/www.programminginpython.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.programminginpython.com\/python-dictionary-operations\/#primaryimage"},"image":{"@id":"https:\/\/www.programminginpython.com\/python-dictionary-operations\/#primaryimage"},"thumbnailUrl":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python-Dictionaries_Wp1.png","datePublished":"2023-03-30T04:56:55+00:00","dateModified":"2023-04-23T12:10:57+00:00","description":"A Python Program demonstrating a Python Dictionary and its operations like adding, modifying and deleting elements from a Python Dictionary.","breadcrumb":{"@id":"https:\/\/www.programminginpython.com\/python-dictionary-operations\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.programminginpython.com\/python-dictionary-operations\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.programminginpython.com\/python-dictionary-operations\/#primaryimage","url":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python-Dictionaries_Wp1.png","contentUrl":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python-Dictionaries_Wp1.png","width":1920,"height":400,"caption":"Python Dictionary and its operations"},{"@type":"BreadcrumbList","@id":"https:\/\/www.programminginpython.com\/python-dictionary-operations\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.programminginpython.com\/"},{"@type":"ListItem","position":2,"name":"Python Dictionary and its operations"}]},{"@type":"WebSite","@id":"https:\/\/www.programminginpython.com\/#website","url":"https:\/\/www.programminginpython.com\/","name":"Programming In Python","description":"All About Python","publisher":{"@id":"https:\/\/www.programminginpython.com\/#organization"},"alternateName":"pip","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.programminginpython.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.programminginpython.com\/#organization","name":"Programming In Python","alternateName":"PIP","url":"https:\/\/www.programminginpython.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.programminginpython.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/04\/pip_logo_500_500.png","contentUrl":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/04\/pip_logo_500_500.png","width":500,"height":500,"caption":"Programming In Python"},"image":{"@id":"https:\/\/www.programminginpython.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/programminginpython","https:\/\/x.com\/python_pip","https:\/\/www.youtube.com\/programminginpython","https:\/\/github.com\/avinashn\/programminginpython.com"]},{"@type":"Person","@id":"https:\/\/www.programminginpython.com\/#\/schema\/person\/9a3c14fe46d422ebf783ee61de1e788c","name":"AVINASH NETHALA","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.programminginpython.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ed52e7670d7db94820c7430d324103ccdecb16d86611d5b29064aa9ce25a958b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ed52e7670d7db94820c7430d324103ccdecb16d86611d5b29064aa9ce25a958b?s=96&d=mm&r=g","caption":"AVINASH NETHALA"},"sameAs":["https:\/\/www.programminginpython.com\/"],"url":"https:\/\/www.programminginpython.com\/author\/avinash\/"}]}},"jetpack_featured_media_url":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/Python-Dictionaries_Wp1.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/posts\/50","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/comments?post=50"}],"version-history":[{"count":4,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/posts\/50\/revisions"}],"predecessor-version":[{"id":656,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/posts\/50\/revisions\/656"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/media\/264"}],"wp:attachment":[{"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/media?parent=50"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/categories?post=50"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/tags?post=50"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}