{"id":18767,"date":"2021-10-27T17:27:33","date_gmt":"2021-10-27T11:57:33","guid":{"rendered":"https:\/\/tutorial.eyehunts.com\/?p=18767"},"modified":"2023-01-18T17:38:34","modified_gmt":"2023-01-18T12:08:34","slug":"python-convert-list-to-dictionary-keys-example-code","status":"publish","type":"post","link":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/","title":{"rendered":"Python convert list to dictionary keys | Example code"},"content":{"rendered":"\n<p>Using <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-dict-comprehension-if-else-example-code\/\">Dictionary Comprehension<\/a> or <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-zip-function\/\">zip() function<\/a> will convert the list to dictionary keys in Python. If you have 2 lists then one list value will be a key and another one is used as the value. <\/p>\n\n\n\n<p>A single list can be used to convert a key for a dictionary but you have to assign some value to them.<\/p>\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>Python convert list to dictionary keys example<\/strong><\/h2>\n\n\n\n<p>Simple example code converting the list into the dictionary. where List stores the heterogeneous data type and Dictionary stores data in key-value pair.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Using Dictionary Comprehension<\/strong><\/p>\n\n\n\n<p>0 assign as a value for every key because the dictionary data is in key-value pair where each key is associated with its value. <a href=\"https:\/\/www.javatpoint.com\/python-dictionary\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>student = &#91;\"James\", \"Tim\", \"Peter\", \"John\"]\n\ndict1 = {stu: 0 for stu in student}\n\nprint(dict1)\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"566\" height=\"127\" src=\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-list-to-dictionary-keys.jpg?resize=566%2C127&#038;ssl=1\" alt=\"Python convert list to dictionary keys\" class=\"wp-image-21671\"\/><\/figure><\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Using zip() function<\/strong><\/p>\n\n\n\n<p>This function is used to zip the two values together. First, create an iterator and initialize it to any variable, and then typecast to the <a href=\"https:\/\/tutorial.eyehunts.com\/python\/init-dict-python-with-example-code\/\"><strong>dict()<\/strong> function<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def get_dict(a):\n\n    init = iter(list1)\n    res_dct = dict(zip(init, init))\n    return res_dct\n\n\nlist1 = &#91;'x', 1, 'y', 2, 'z', 3]\nprint(get_dict(list1))\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>: {&#8216;x&#8217;: 1, &#8216;y&#8217;: 2, &#8216;z&#8217;: 3}<\/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 or suggestions on this Python list dictionary 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 Dictionary Comprehension or zip() function will convert the list to dictionary keys in Python. If you have 2 lists then one list value will be a key and another one is used as the value. A single list can be used to convert a key for a dictionary but you have to assign some&hellip;&nbsp;<a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Python convert list to dictionary keys | 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-18767","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>Python convert list to dictionary keys | Example code<\/title>\n<meta name=\"description\" content=\"Using Dictionary Comprehension or zip() function will convert list to dictionary keys in Python. If you have 2 lists then one list value will\" \/>\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\/python-convert-list-to-dictionary-keys-example-code\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python convert list to dictionary keys | Example code\" \/>\n<meta property=\"og:description\" content=\"Using Dictionary Comprehension or zip() function will convert list to dictionary keys in Python. If you have 2 lists then one list value will\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2021-10-27T11:57:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-18T12:08:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-list-to-dictionary-keys.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\/python-convert-list-to-dictionary-keys-example-code\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/\",\"name\":\"Python convert list to dictionary keys | Example code\",\"isPartOf\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-list-to-dictionary-keys.jpg\",\"datePublished\":\"2021-10-27T11:57:33+00:00\",\"dateModified\":\"2023-01-18T12:08:34+00:00\",\"author\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\"},\"description\":\"Using Dictionary Comprehension or zip() function will convert list to dictionary keys in Python. If you have 2 lists then one list value will\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-list-to-dictionary-keys.jpg?fit=566%2C127&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-list-to-dictionary-keys.jpg?fit=566%2C127&ssl=1\",\"width\":566,\"height\":127},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorial.eyehunts.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python convert list to dictionary keys | 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":"Python convert list to dictionary keys | Example code","description":"Using Dictionary Comprehension or zip() function will convert list to dictionary keys in Python. If you have 2 lists then one list value will","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\/python-convert-list-to-dictionary-keys-example-code\/","og_locale":"en_US","og_type":"article","og_title":"Python convert list to dictionary keys | Example code","og_description":"Using Dictionary Comprehension or zip() function will convert list to dictionary keys in Python. If you have 2 lists then one list value will","og_url":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/","og_site_name":"Tutorial","article_published_time":"2021-10-27T11:57:33+00:00","article_modified_time":"2023-01-18T12:08:34+00:00","og_image":[{"url":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-list-to-dictionary-keys.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\/python-convert-list-to-dictionary-keys-example-code\/","url":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/","name":"Python convert list to dictionary keys | Example code","isPartOf":{"@id":"https:\/\/tutorial.eyehunts.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/#primaryimage"},"image":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/#primaryimage"},"thumbnailUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-list-to-dictionary-keys.jpg","datePublished":"2021-10-27T11:57:33+00:00","dateModified":"2023-01-18T12:08:34+00:00","author":{"@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1"},"description":"Using Dictionary Comprehension or zip() function will convert list to dictionary keys in Python. If you have 2 lists then one list value will","breadcrumb":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/#primaryimage","url":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-list-to-dictionary-keys.jpg?fit=566%2C127&ssl=1","contentUrl":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-convert-list-to-dictionary-keys.jpg?fit=566%2C127&ssl=1","width":566,"height":127},{"@type":"BreadcrumbList","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-keys-example-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorial.eyehunts.com\/"},{"@type":"ListItem","position":2,"name":"Python convert list to dictionary keys | 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":18678,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-dictionary-to-list\/","url_meta":{"origin":18767,"position":0},"title":"Python dictionary to list","author":"Rohit","date":"July 21, 2023","format":false,"excerpt":"Converting a Python dictionary to a list can be done in multiple ways depending on how you want the list to be structured. Here are a few common methods: List of keys: If you only want to extract the keys from the dictionary and store them in a list, you\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-dictionary-to-list.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/07\/Python-dictionary-to-list.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/07\/Python-dictionary-to-list.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/07\/Python-dictionary-to-list.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":18727,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-create-dictionary-from-list-example-code\/","url_meta":{"origin":18767,"position":1},"title":"Python create dictionary from list | Example code","author":"Rohit","date":"August 30, 2021","format":false,"excerpt":"There are multiple ways to create a dictionary from the list in python. A dict comprehension and zip() function are common and simple to create a dictionary from a list. Must read: Python make dict from list Example create a dictionary from the list in Python Simple example code. Using\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python create dictionary from list","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Python-create-dictionary-from-list.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":41190,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-dictionary-keys-method\/","url_meta":{"origin":18767,"position":2},"title":"Python Dictionary keys() method","author":"Rohit","date":"July 24, 2023","format":false,"excerpt":"In Python, the keys() method is a built-in method for dictionaries, which returns a dictionary view object containing all the keys of the dictionary. This method allows you to access the keys of the dictionary in a dynamic way, as it provides a view that reflects any changes made to\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-Dictionary-keys-method.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/07\/Python-Dictionary-keys-method.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/07\/Python-Dictionary-keys-method.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":18769,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-convert-list-to-dictionary-with-index-as-key-example-code\/","url_meta":{"origin":18767,"position":3},"title":"Python convert list to Dictionary with index as key | Example code","author":"Rohit","date":"August 30, 2021","format":false,"excerpt":"Want to convert the given list: list = ['A','B','C'] To a dictionary output look like this: Where values of key based on the current index value of the element in the list. dict = {'A':0, 'B':1, 'C':2} Example convert list to a dictionary with index as a key in Python\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python convert list to Dictionary with index as key","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Python-convert-list-to-Dictionary-with-index-as-key.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":23808,"url":"https:\/\/tutorial.eyehunts.com\/python\/map-list-to-dictionary-python-example-code\/","url_meta":{"origin":18767,"position":4},"title":"Map list to dictionary Python | Example code","author":"Rohit","date":"December 26, 2021","format":false,"excerpt":"Using the zip( ) function or dictionary comprehension you can convert the Map list to the dictionary in Python Dictionary comprehension syntax: def foo(somelist): return {x[0]:x for x in somelist} Example Map list to dictionary Python A simple example code function that will return the name of a key, and\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\/12\/Map-list-to-dictionary-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":19064,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-dictionary-values-to-list-example-code\/","url_meta":{"origin":18767,"position":5},"title":"Python dictionary values to list | Example code","author":"Rohit","date":"September 6, 2021","format":false,"excerpt":"Use the Python inbuild values() method to get values of the dictionary. The dict.values return a view of the dictionary\u2019s values instead. dictonary.values() Python example dictionary values to the list Simple example code. The first values() method creates a view of the dictionary's values then Use a list(item) with the\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python dictionary values to list","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/09\/Python-dictionary-values-to-list.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/18767","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=18767"}],"version-history":[{"count":1,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/18767\/revisions"}],"predecessor-version":[{"id":35580,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/18767\/revisions\/35580"}],"wp:attachment":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/media?parent=18767"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/categories?post=18767"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/tags?post=18767"},{"taxonomy":"post_series","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/post_series?post=18767"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}