{"id":18302,"date":"2021-08-22T10:01:49","date_gmt":"2021-08-22T04:31:49","guid":{"rendered":"https:\/\/tutorial.eyehunts.com\/?p=18302"},"modified":"2022-01-05T18:48:57","modified_gmt":"2022-01-05T13:18:57","slug":"remove-duplicate-dictionaries-from-list-python-example-code","status":"publish","type":"post","link":"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/","title":{"rendered":"Remove duplicate dictionaries from list Python | Example code"},"content":{"rendered":"\n<p>Using set can remove duplicate dictionaries from list Python. First,  transform the initial dict into a list of tuples, then put them into a set (that removes duplicate entries), and then back into a dict.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;dict(t) for t in {tuple(d.items()) for d in l}]<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Example remove duplicate dict in list in Python<\/strong><\/h2>\n\n\n\n<p>Simple example code.<\/p>\n\n\n\n<p>Convert the list of dictionaries to a list of <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-tuples-tuorial-example\/\">tuples <\/a>where the tuples contain the items of the dictionary. Since the tuples can be hashed, you can remove duplicates using set (using a set comprehension here, an older python alternative would be set(tuple(d.items()) for d in l)) and, after that, re-create the dictionaries from tuples with dict.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>l = &#91;{'a': 10, 'b': 4},\n     {'a': 20, 'b': 4},\n     {'a': 10, 'b': 4}]\n\nseen = set()\nnew_l = &#91;]\nfor d in l:\n    t = tuple(d.items())\n    if t not in seen:\n        seen.add(t)\n        new_l.append(d)\n\nprint(new_l)\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"516\" height=\"152\" src=\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-duplicate-dictionaries-from-list-Python.jpg?resize=516%2C152&#038;ssl=1\" alt=\"\" class=\"wp-image-18368\"\/><\/figure><\/div>\n\n\n\n<p><strong>Source<\/strong>: stackoverflow.com<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Remove Duplicate Dictionaries characterized by Key<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>test_list = &#91;{\"A\": 6, \"is\": 19, \"best\": 1},\n             {\"A\": 8, \"is\": 11, \"best\": 9},\n             {\"A\": 2, \"is\": 16, \"best\": 1},\n             {\"A\": 12, \"is\": 11, \"best\": 8},\n             {\"A\": 22, \"is\": 16, \"best\": 8}]\n\n# initializing Key \nK = \"best\"\n\nmemo = set()\nres = &#91;]\nfor sub in test_list:\n\n    # testing for already present value\n    if sub&#91;K] not in memo:\n        res.append(sub)\n\n        # adding in memo if new value\n        memo.add(sub&#91;K])\n\n# printing result \nprint(str(res))\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>: [{&#8216;A&#8217;: 6, &#8216;is&#8217;: 19, &#8216;best&#8217;: 1}, {&#8216;A&#8217;: 8, &#8216;is&#8217;: 11, &#8216;best&#8217;: 9}, {&#8216;A&#8217;: 12, &#8216;is&#8217;: 11, &#8216;best&#8217;: 8}]<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Do comment if you have any doubts and suggestions on this Python dictionaries topic.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note:<\/strong> IDE:&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.jetbrains.com\/pycharm\/\" target=\"_blank\">PyCharm<\/a>&nbsp;2021.3.3 (Community Edition)<\/p><p>Windows 10<\/p><p><strong>Python 3.10.1<\/strong><\/p><p>All<strong>&nbsp;Python Examples&nbsp;are in&nbsp;Python&nbsp;3<\/strong>, so Maybe its different from python 2 or upgraded versions.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Using set can remove duplicate dictionaries from list Python. First, transform the initial dict into a list of tuples, then put them into a set (that removes duplicate entries), and then back into a dict. Example remove duplicate dict in list in Python Simple example code. Convert the list of dictionaries to a list of&hellip;&nbsp;<a href=\"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Remove duplicate dictionaries from list Python | Example code<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[30],"tags":[101,83],"post_series":[],"class_list":["post-18302","post","type-post","status-publish","format-standard","hentry","category-python","tag-python-dictionary","tag-python-list"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Remove duplicate dictionaries from list Python | Example code - EyeHunts<\/title>\n<meta name=\"description\" content=\"Using set can remove duplicate dictionaries from list Python. First, transform the initial dict into a list of tuples, then put them into...\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Remove duplicate dictionaries from list Python | Example code - EyeHunts\" \/>\n<meta property=\"og:description\" content=\"Using set can remove duplicate dictionaries from list Python. First, transform the initial dict into a list of tuples, then put them into...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-22T04:31:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-01-05T13:18:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-duplicate-dictionaries-from-list-Python.jpg\" \/>\n<meta name=\"author\" content=\"Rohit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rohit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/\",\"name\":\"Remove duplicate dictionaries from list Python | Example code - EyeHunts\",\"isPartOf\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-duplicate-dictionaries-from-list-Python.jpg\",\"datePublished\":\"2021-08-22T04:31:49+00:00\",\"dateModified\":\"2022-01-05T13:18:57+00:00\",\"author\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\"},\"description\":\"Using set can remove duplicate dictionaries from list Python. First, transform the initial dict into a list of tuples, then put them into...\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-duplicate-dictionaries-from-list-Python.jpg?fit=516%2C152&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-duplicate-dictionaries-from-list-Python.jpg?fit=516%2C152&ssl=1\",\"width\":516,\"height\":152},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorial.eyehunts.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Remove duplicate dictionaries from list Python | Example code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\",\"url\":\"https:\/\/tutorial.eyehunts.com\/\",\"name\":\"Tutorial\",\"description\":\"By EyeHunts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\",\"name\":\"Rohit\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971\",\"contentUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971\",\"caption\":\"Rohit\"},\"description\":\"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.\",\"url\":\"https:\/\/tutorial.eyehunts.com\/author\/rohit\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Remove duplicate dictionaries from list Python | Example code - EyeHunts","description":"Using set can remove duplicate dictionaries from list Python. First, transform the initial dict into a list of tuples, then put them into...","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/","og_locale":"en_US","og_type":"article","og_title":"Remove duplicate dictionaries from list Python | Example code - EyeHunts","og_description":"Using set can remove duplicate dictionaries from list Python. First, transform the initial dict into a list of tuples, then put them into...","og_url":"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/","og_site_name":"Tutorial","article_published_time":"2021-08-22T04:31:49+00:00","article_modified_time":"2022-01-05T13:18:57+00:00","og_image":[{"url":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-duplicate-dictionaries-from-list-Python.jpg","type":"","width":"","height":""}],"author":"Rohit","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rohit","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/","url":"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/","name":"Remove duplicate dictionaries from list Python | Example code - EyeHunts","isPartOf":{"@id":"https:\/\/tutorial.eyehunts.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/#primaryimage"},"image":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/#primaryimage"},"thumbnailUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-duplicate-dictionaries-from-list-Python.jpg","datePublished":"2021-08-22T04:31:49+00:00","dateModified":"2022-01-05T13:18:57+00:00","author":{"@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1"},"description":"Using set can remove duplicate dictionaries from list Python. First, transform the initial dict into a list of tuples, then put them into...","breadcrumb":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/#primaryimage","url":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-duplicate-dictionaries-from-list-Python.jpg?fit=516%2C152&ssl=1","contentUrl":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-duplicate-dictionaries-from-list-Python.jpg?fit=516%2C152&ssl=1","width":516,"height":152},{"@type":"BreadcrumbList","@id":"https:\/\/tutorial.eyehunts.com\/python\/remove-duplicate-dictionaries-from-list-python-example-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorial.eyehunts.com\/"},{"@type":"ListItem","position":2,"name":"Remove duplicate dictionaries from list Python | Example code"}]},{"@type":"WebSite","@id":"https:\/\/tutorial.eyehunts.com\/#website","url":"https:\/\/tutorial.eyehunts.com\/","name":"Tutorial","description":"By EyeHunts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1","name":"Rohit","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/","url":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971","contentUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971","caption":"Rohit"},"description":"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.","url":"https:\/\/tutorial.eyehunts.com\/author\/rohit\/"}]}},"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":8469,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-iterable-object-lists-tuples-dictionaries-and-sets\/","url_meta":{"origin":18302,"position":0},"title":"Python iterable object | Lists, tuples, dictionaries, and sets","author":"Rohit","date":"May 17, 2020","format":false,"excerpt":"Python iterable objects are capable of returning their members one at a time, permitting them to be iterated over in a for-loop. Examples of iterable include all sequence types (such as list, str, and tuple) and some non-sequence types like dict, file objects, and objects of any classes you define\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/05\/Python-iterable-object-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/05\/Python-iterable-object-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/05\/Python-iterable-object-1.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/05\/Python-iterable-object-1.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":40492,"url":"https:\/\/tutorial.eyehunts.com\/python\/difference-between-list-and-dictionary-in-python\/","url_meta":{"origin":18302,"position":1},"title":"Difference between list and dictionary in Python","author":"Rohit","date":"June 28, 2023","format":false,"excerpt":"The difference between lists and dictionaries in Python lies in their structure, access methods, mutability, and usage. Lists are ordered collections that store elements based on their positions, while dictionaries are unordered collections of key-value pairs accessed via unique keys. Lists allow duplicate values and support indexing, while dictionaries require\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/06\/Difference-between-list-and-dictionary-in-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/06\/Difference-between-list-and-dictionary-in-Python.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/06\/Difference-between-list-and-dictionary-in-Python.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":8087,"url":"https:\/\/tutorial.eyehunts.com\/python\/len-python-function-to-get-length-string-array-list-tuple-dictionary\/","url_meta":{"origin":18302,"position":2},"title":"len Python | Function to get a length of string, array, list, tuple, dictionary, etc","author":"Rohit","date":"April 21, 2020","format":false,"excerpt":"A \"len Python\" is an inbuilt function and use for getting the number of items (length) in an object. A len() function can get the length of String, list (Array), tuple, dictionary, etc in Python. Syntax The syntax of len() is: len(object) Parameters Object\u00a0- a sequence (string, bytes, tuple, list,\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/len-Python-Function-get-length-string-array-list-tuple-dictionary-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/len-Python-Function-get-length-string-array-list-tuple-dictionary-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/len-Python-Function-get-length-string-array-list-tuple-dictionary-1.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/len-Python-Function-get-length-string-array-list-tuple-dictionary-1.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":19088,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-sort-dict-by-value-descending-example-code\/","url_meta":{"origin":18302,"position":3},"title":"Python sort dict by value descending | Example code","author":"Rohit","date":"December 6, 2021","format":false,"excerpt":"Use the operator itemgetter method to sort dict by value descending in Python. operator.itemgetter(1) takes the value of the key which is at the index 1. Example sort dict by value descending in Python Simple example code. You have to import operator module to use the itemgetter method. import operator\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python sort dict by value descending","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/Python-sort-dict-by-value-descending.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":18611,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-print-dictionary-keys-and-values-example-code\/","url_meta":{"origin":18302,"position":4},"title":"Python print dictionary keys and values | Example code","author":"Rohit","date":"August 27, 2021","format":false,"excerpt":"The simple and most used method is \"in operator\" to get dictionary keys and values in Python. Once you have dit keys and values then print them one by one within a for-loop. Example print dictionary keys and values in Python Simple example code. dict1 = {\"A\": 10, \"B\": 20,\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Python-print-dictionary-keys-and-values.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":36680,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-hashable-dict\/","url_meta":{"origin":18302,"position":5},"title":"Python Hashable Dict","author":"Rohit","date":"July 5, 2023","format":false,"excerpt":"In Python, dictionaries are not hashable by default because they are mutable. However, you can create a hashable dictionary by using an immutable data structure to represent the dictionary. One way to create a hashable dictionary is by converting it into a frozenset of its items. Here's an example: my_dict\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/07\/Python-Hashable-Dict.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/07\/Python-Hashable-Dict.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/07\/Python-Hashable-Dict.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/18302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/comments?post=18302"}],"version-history":[{"count":1,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/18302\/revisions"}],"predecessor-version":[{"id":24032,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/18302\/revisions\/24032"}],"wp:attachment":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/media?parent=18302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/categories?post=18302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/tags?post=18302"},{"taxonomy":"post_series","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/post_series?post=18302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}