{"id":15980,"date":"2021-01-14T23:41:02","date_gmt":"2021-01-15T07:41:02","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=15980"},"modified":"2023-12-01T04:08:06","modified_gmt":"2023-12-01T12:08:06","slug":"python-convert-list-to-dictionary","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/","title":{"rendered":"Python Convert List to Dictionary: A Complete Guide"},"content":{"rendered":"\n<p><em>You can convert a Python list to a dictionary using a dictionary comprehension, dict.fromkeys(), or the zip() method. All three methods create a new dictionary. They do not modify the existing list.<\/em><\/p>\n\n\n\n<p>Python lists and dictionaries are two structures used to store data. But what if you want to convert a list into a dictionary? You may want to do this if you want to assign a unique label to each value you have stored. This is only possible in a dictionary.<\/p>\n\n\n\n<p>There are a few techniques and built-in functions you can use in Python to convert a list to a dictionary. This programming tutorial will discuss, with reference to examples, how to convert a list into a dictionary in Python.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Lists and Dictionaries<\/h2>\n\n\n\n<p>Lists and dictionaries are examples of Python collections. They allow you to store multiple similar values together in one data structure.<\/p>\n\n\n\n<p>The list data structure allows you to store data in a specific order. Here is an example of a Python list:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>takeout_prices = [2.50, 2.75, 4.50, 5.00]<\/pre><\/div>\n\n\n\n<p>Our list called <em>takeout_prices<\/em> contains four values.<\/p>\n\n\n\n<p>Dictionaries, on the other hand, are unordered, and cannot store multiple duplicate values.<\/p>\n\n\n\n<p>Here is an example of a <a href=\"https:\/\/careerkarma.com\/blog\/python-dictionary\/\">Python dictionary<\/a>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>takeout_prices = {\n\t'single_chips': 2.50,\n\t'large_chips': 2.75,\n\t'single_fish': 4.50,\n\t'large_fish': 5.00\n}<\/pre><\/div>\n\n\n\n<p>Dictionaries are useful if you want to associate labels with each value. Lists are better if you are storing similar data, such as a list of prices or names, where you cannot label each value.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Convert List to Dictionary<\/h2>\n\n\n\n<p>You can convert a Python list to a dictionary using the dict.fromkeys() method, a dictionary comprehension, or the zip() method. The zip() method is useful if you want to merge two lists into a dictionary.<\/p>\n\n\n\n<p>Let&#8217;s quickly summarize these methods:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><em>dict.fromkeys()<\/em>: Used to create a dictionary from a list. You can optionally set a default value for all keys. You cannot set individual values for each item in the dictionary.<\/li><li>Dictionary comprehension: Creates a new dictionary from an existing list. You can specify different values for each key in the dictionary. Dictionary comprehensions are similar to <a href=\"https:\/\/careerkarma.com\/blog\/python-list-comprehension\/\">Python list comprehensions<\/a> in structure.<\/li><li><em>zip()<\/em>: Converts two or more lists into a list of tuples. You can use the dict() method to convert the list of tuples into a dictionary.<\/li><\/ul>\n\n\n\n<p>We&#8217;re going to use each of the three methods above to demonstrate how we can convert a list into a dictionary.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Convert List to Dictionary: dict.fromkeys()<\/h2>\n\n\n\n<p>Say that we have a list of fruits that we want to turn into a dictionary. The value assigned to each fruit should be <em>In stock<\/em>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>fruits = [&quot;Apple&quot;, &quot;Pear&quot;, &quot;Peach&quot;, &quot;Banana&quot;]<\/pre><\/div>\n\n\n\n<p>We could create this dictionary using the <em>dict.fromkeys()<\/em> method. This method accepts a list of keys that you want to turn into a dictionary. Optionally, you can specify a value you want to assign to every key.<\/p>\n\n\n\n<p>You can only specify one value to be assigned to every key. You cannot say that one key should have one value and another key should have a different value.<\/p>\n\n\n\n<p>Let&#8217;s turn our list of fruits into a dictionary:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>fruits = [&quot;Apple&quot;, &quot;Pear&quot;, &quot;Peach&quot;, &quot;Banana&quot;]\n\nfruit_dictionary = dict.fromkeys(fruits, &quot;In stock&quot;)\n\nprint(fruit_dictionary)<\/pre><\/div>\n\n\n\n<p>Our code returns the objects from this list in a dictionary object:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>{'Apple': 'In stock', 'Pear': 'In stock', 'Peach': 'In stock', 'Banana': 'In stock'}<\/pre><\/div>\n\n\n\n<p>We first declare a <a href=\"https:\/\/careerkarma.com\/blog\/python-variables\/\">Python variable<\/a> called <em>fruits<\/em> which stores the names of the keys we want to use in our dictionary.<\/p>\n\n\n\n<p>We use <em>dict.fromkeys()<\/em> to create a dictionary that uses the key names we stored in the <em>fruits<\/em> array. This method assigns the value of each key to be <em>In stock<\/em>. Finally, we print the new dictionary to the console.<\/p>\n\n\n\n<p>If we did not specify the value <em>In stock<\/em> in our code, the default value for the keys in our dictionary would be None.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Convert List to Dictionary Python: Dictionary Comprehension<\/h2>\n\n\n\n<p>We can also use a technique called <em>dictionary comprehension<\/em> to convert a Python list to a dictionary using the same values.<\/p>\n\n\n\n<p>A dictionary comprehension is similar to a list comprehension in that both methods create a new value of their respective data types. Dictionary comprehensions use pointed brackets ({}) whereas list comprehensions use square brackets ([]).<\/p>\n\n\n\n<p>Let&#8217;s convert our list of fruits to a dictionary using dictionary comprehension:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>fruits = [&quot;Apple&quot;, &quot;Pear&quot;, &quot;Peach&quot;, &quot;Banana&quot;]\n\nfruit_dictionary = { fruit : &quot;In stock&quot; for fruit in fruits }\n\nprint(fruit_dictionary)<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>{'Apple': 'In stock', 'Pear': 'In stock', 'Peach': 'In stock', 'Banana': 'In stock'}<\/pre><\/div>\n\n\n\n<p>First, we declared a list called <em>fruits<\/em> which stored the names we wanted to move into a dictionary.<\/p>\n\n\n\n<p>Then, we used dictionary comprehension to run through each item in the <em>fruits<\/em> list. We add an item to our new dictionary for each fruit in our list. The value we assigned to each fruit was <em>In stock<\/em>. Finally, we printed out our new dictionary to the console.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Convert List to Dictionary: zip()<\/h2>\n\n\n\n<p>In our last example, we have converted a single list into a dictionary and assigned a default value for each item in the dictionary. However, it is possible to convert two lists into a dictionary.<\/p>\n\n\n\n<p>To do so, we can use the <a href=\"https:\/\/careerkarma.com\/blog\/python-zip\">Python <em>zip()<\/em> function<\/a>. This function lets us merge two lists together. We can use one list as the keys for the dictionary and the other as the values.<\/p>\n\n\n\n<p>Suppose we have two lists: one containing a list of fruits, and the other containing the price for an individual piece of fruit. We want to create a single dictionary that stores the name of a fruit, alongside its price. We can use the following code to accomplish this task:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>fruits = [&quot;Apple&quot;, &quot;Pear&quot;, &quot;Peach&quot;, &quot;Banana&quot;]\nprices = [0.35, 0.40, 0.40, 0.28]\n\nfruit_dictionary = dict(zip(fruits, prices))\n\nprint(fruit_dictionary)<\/pre><\/div>\n\n\n\n<p>Our code returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>{'Apple': 0.35, 'Pear': 0.4, 'Peach': 0.4, 'Banana': 0.28}<\/pre><\/div>\n\n\n\n<p>First, we have specified two lists: a list of fruits, and a list of prices. Then, we have used the <em>zip()<\/em> function to merge our two lists together. The <em>zip()<\/em> function returns a list of merged tuples. Because we want a dictionary, we have used <em>dict()<\/em> to convert our tuples into a dictionary.<\/p>\n\n\n\n<p>Next, we printed the contents of our new dictionary to the console.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>To convert a list to a dictionary using the same values, you can use the <em>dict.fromkeys()<\/em> method. To convert two lists into one dictionary, you can use the Python <em>zip()<\/em> function. The dictionary comprehension lets you create a new dictionary based on the values of a list.<\/p>\n\n\n\n<p>In this tutorial, we used examples to demonstrate how to use three approaches to convert a list to a dictionary in Python. Now you\u2019re ready to start converting Python lists to dictionaries like a professional programmer!<\/p>\n\n\n\n<p>Are you interested in learning more about 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 online courses, books, and learning resources you can use to build your knowledge of coding in Python.<\/p>\n","protected":false},"excerpt":{"rendered":"You can convert a Python list to a dictionary using a dictionary comprehension, dict.fromkeys(), or the zip() method. All three methods create a new dictionary. They do not modify the existing list. Python lists and dictionaries are two structures used to store data. But what if you want to convert a list into a dictionary?&hellip;","protected":false},"author":240,"featured_media":15981,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-15980","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Python","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python Convert List to Dictionary: A Complete Guide: A Complete Guide<\/title>\n<meta name=\"description\" content=\"On Career Karma, learn how to convert a list to a dictionary using dictionary comprehension, the dict.fromkeys() method, and the zip() function.\" \/>\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-convert-list-to-dictionary\/\" \/>\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: A Complete Guide\" \/>\n<meta property=\"og:description\" content=\"On Career Karma, learn how to convert a list to a dictionary using dictionary comprehension, the dict.fromkeys() method, and the zip() function.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-convert-list-to-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-15T07:41:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:08:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/adult-business-computer-contemporary-380769.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"573\" \/>\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-convert-list-to-dictionary\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python Convert List to Dictionary: A Complete Guide\",\"datePublished\":\"2021-01-15T07:41:02+00:00\",\"dateModified\":\"2023-12-01T12:08:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/\"},\"wordCount\":1067,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/adult-business-computer-contemporary-380769.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/\",\"name\":\"Python Convert List to Dictionary: A Complete Guide: A Complete Guide\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/adult-business-computer-contemporary-380769.jpg\",\"datePublished\":\"2021-01-15T07:41:02+00:00\",\"dateModified\":\"2023-12-01T12:08:06+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"On Career Karma, learn how to convert a list to a dictionary using dictionary comprehension, the dict.fromkeys() method, and the zip() function.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/adult-business-computer-contemporary-380769.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/adult-business-computer-contemporary-380769.jpg\",\"width\":1020,\"height\":573},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-convert-list-to-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 Convert List to 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\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Convert List to Dictionary: A Complete Guide: A Complete Guide","description":"On Career Karma, learn how to convert a list to a dictionary using dictionary comprehension, the dict.fromkeys() method, and the zip() function.","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-convert-list-to-dictionary\/","og_locale":"en_US","og_type":"article","og_title":"Python Convert List to Dictionary: A Complete Guide","og_description":"On Career Karma, learn how to convert a list to a dictionary using dictionary comprehension, the dict.fromkeys() method, and the zip() function.","og_url":"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2021-01-15T07:41:02+00:00","article_modified_time":"2023-12-01T12:08:06+00:00","og_image":[{"width":1020,"height":573,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/adult-business-computer-contemporary-380769.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-convert-list-to-dictionary\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python Convert List to Dictionary: A Complete Guide","datePublished":"2021-01-15T07:41:02+00:00","dateModified":"2023-12-01T12:08:06+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/"},"wordCount":1067,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/adult-business-computer-contemporary-380769.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/","url":"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/","name":"Python Convert List to Dictionary: A Complete Guide: A Complete Guide","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/adult-business-computer-contemporary-380769.jpg","datePublished":"2021-01-15T07:41:02+00:00","dateModified":"2023-12-01T12:08:06+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"On Career Karma, learn how to convert a list to a dictionary using dictionary comprehension, the dict.fromkeys() method, and the zip() function.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-convert-list-to-dictionary\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/adult-business-computer-contemporary-380769.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/adult-business-computer-contemporary-380769.jpg","width":1020,"height":573},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-convert-list-to-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 Convert List to 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\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/15980","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=15980"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/15980\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/15981"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=15980"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=15980"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=15980"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}