{"id":7489,"date":"2025-03-27T06:28:05","date_gmt":"2025-03-27T06:28:05","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=7489"},"modified":"2025-03-27T07:38:24","modified_gmt":"2025-03-27T07:38:24","slug":"how-to-create-dictionary-from-lists-in-python","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/","title":{"rendered":"How to Create Dictionary from Lists in Python"},"content":{"rendered":"\n<p>Python developers often use lists and dictionaries to store data. They are both very powerful data types which offer many functionalities. Sometimes, you may need to create dictionary from lists in Python. There are several ways to do this. In this article, we will learn how to build a dictionary using two lists &#8211; one for keys and another for values.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#Why_Create_Dictionary_from_Lists\" >Why Create Dictionary from Lists<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#How_to_Create_Dictionary_from_Lists_in_Python\" >How to Create Dictionary from Lists in Python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#1_Using_Dict_Constructor_with_Zip\" >1. Using Dict Constructor with Zip<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#2_Using_Dictionary_Comprehension\" >2. Using Dictionary Comprehension<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#3_Using_itertools\" >3. Using itertools<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#4_Using_for_loop\" >4. Using for loop<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Create_Dictionary_from_Lists\"><\/span>Why Create Dictionary from Lists<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Dictionary is a very useful data structure that allows you to store data as key-value pairs. It can be easily converted into JSON and vice versa. But sometimes the data that you receive or import may be present as lists. In such cases, you will need to create dictionary from lists.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Create_Dictionary_from_Lists_in_Python\"><\/span>How to Create Dictionary from Lists in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let us say you have the following two lists.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">keys = ['name', 'age', 'fruit']<br>values = ['John', 22, 'apple']<\/pre>\n\n\n\n<p>Let us say you want to convert the above lists into the following dictionary.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{'name': 'John', 'age': 22, 'fruit': 'apple'}<\/pre>\n\n\n\n<p>Let us look at the different ways to transform data this way.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Using_Dict_Constructor_with_Zip\"><\/span>1. Using Dict Constructor with Zip<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this solution, we use a combination of dict constructor and zip function together. Zip function accepts 2 iterable objects like lists, and returns an iterator of tuples where the first passed iterator is the 1st items of both lists paired together, the second passed iterator is the 2nd items of both lists paired together, and so on. If both lists have unequal number of items, then the result will have number of iterables equal to the smaller list.<\/p>\n\n\n\n<p>Here is the syntax to convert the 2 lists into a dictionary.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">new_dict = dict(zip(keys, values))<br>print(new_dict) # output is <\/pre>\n\n\n\n<p>In the above code, we enclose the result of zip() function into dict constructor. The dict constructor returns an empty dictionary or converts other data types to dictionary. So this code will return a dict result.<\/p>\n\n\n\n<p>This approach is very fast and scalable. It does not create any intermediate data structures, and works mainly using iterators.<\/p>\n\n\n\n<p>Please note, you need to use the dict constructor instead of wrapping the result of zip() function in curly braces {&#8230;}. Otherwise, you will get a zip object instead of dictionary.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">new_dict = {zip(keys, values)}<br>print(new_dict) # output is {&lt;zip object at 0x7bfe90a96040&gt;}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Using_Dictionary_Comprehension\"><\/span>2. Using Dictionary Comprehension<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Dictionary comprehension is similar to list comprehension. It allows you to create dictionaries from lists using a single line expression. Here is the code to create our dictionary.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">new_dict = {k: v for k, v in zip(keys, values)}<\/pre>\n\n\n\n<p>In the above code, zip function returns a series of iterables for tuples. Here each tuple consists of a pair of items from both the lists &#8211; pair of 1st items, 2nd items, and so on.<\/p>\n\n\n\n<p>The dict comprehension will loop through the result. In each iteration, it will pick a tuple from the result of zip function and assign one item as k and the other item as v. Each k-v pair is assigned as key-value pair to the new_dict dictionary.<\/p>\n\n\n\n<p>This solution is very easy to understand and optimized for high performance. Unlike the previous solution, you can always customize the dict comprehension, to include\/exclude certain items.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Using_itertools\"><\/span>3. Using itertools<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you are using older Python such as Python &lt;=2.6 then the zip function in those versions creates a list of tuples in result. This can take up a lot of space if your lists are big. On the other hand, the zip function in Python 3 returns iterators to tuples and do not take up much space. So if you are using older Python versions, then you can use izip function available in itertools, which works the same way as zip function in Python 3.<\/p>\n\n\n\n<p>Here is the code to convert list to dictionary using izip.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from itertools import izip<br>new_dict = dict(izip(keys, values))<br>print(new_dict)  # output is {'name': 'John', 'age': 22, 'fruit': 'apple'}<\/pre>\n\n\n\n<p>This method works when both the lists have the same length. If one list is longer than the other then the length of dictionary will be same as that of the shorter list.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">keys = ['name', 'age', 'fruit', 'marks']<br>values = ['John', 22, 'apple']<br>new_dict=dict(zip(keys,values))<br>OR<br>new_dict=dict(izip(keys,values))<br>print(new_dict) # output is {'name': 'John', 'age': 22, 'fruit': 'apple'}<\/pre>\n\n\n\n<p>If you want the dict to be as long as the longer list, then you need to use zip_longest function instead of using zip or izip. In this case, all those items in longer list, that do not have equivalent in smaller list, will be filled with None values. Here is an example where we have more keys than values. In such cases, all the keys without corresponding values will be filled with None.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from itertools import zip_longest<br>keys = ['name', 'age', 'fruit', 'marks', 'height']<br>values = ['John', 22, 'apple']<br>new_dict=dict(zip_longest(keys,values))<br>print(new_dict) # output is {'name': 'John', 'age': 22, 'fruit': 'apple', 'marks': None, 'height':None}<\/pre>\n\n\n\n<p>On the other hand, if there are more values than keys, then one key with value None will be assigned the last extra value.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from itertools import zip_longest<br>keys = ['name', 'age', 'fruit']<br>values = ['John', 22, 'apple',23, 24, 5]<br>new_dict=dict(zip_longest(keys,values))<br>print(new_dict) # output is {'name': 'John', 'age': 22, 'fruit': 'apple', <strong>None: 5<\/strong>}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Using_for_loop\"><\/span>4. Using for loop<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This is the most basic but one of the most customizable solution. We simply loop through a list and in each iteration assign key-value pairs. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">keys = ['name', 'age', 'fruit']<br>values = ['John', 22, 'apple']<br>new_dict={}<br>for k, v in zip(keys,values):<br>    new_dict[k]=v<br>print(new_dict) # output is {'name': 'John', 'age': 22, 'fruit': 'apple'}<\/pre>\n\n\n\n<p>In the above code, we define an empty dictionary new_dict to store key-value pairs. We call zip() function on keys and values lists so that we get an iterator of 2-item tuples where each pair is from one list. In each iteration, we use this key and value to create a dictionary key-value pair.<\/p>\n\n\n\n<p>This method is slower than other methods but it is easy to understand for beginners and very easy to customize as per your requirement. For example, you can choose to ignore age-22 key-value pair from dictionary as shown.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">for k, v in zip(keys,values):<br>    if k!='age' and v!=22:<br>        new_dict[k]=v<br>print(new_dict)  # output is {'name': 'John', 'fruit': 'apple'}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we have learnt how to create dictionary from lists in Python. If you want to do the conversion directly without any exclusions or modifications to the list items, then you can use a combination of dict constructor and zip function. If you want to do some customization during dict creation then you can use dict comprehension or for loop.<\/p>\n\n\n\n<p>Also read:<\/p>\n\n\n\n<p><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/\">How to Remove Duplicates from List in Python<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-insert-new-column-to-pandas-dataframe\/\">How to Insert New Column to Pandas Dataframe<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-change-order-of-dataframe-columns-in-python\/\">How to Change Order of Dataframe Columns<\/a><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you may need to create dictionary from lists in Python. Here are different ways to do this.<\/p>\n","protected":false},"author":1,"featured_media":7512,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[301],"tags":[401],"class_list":["post-7489","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-dict-from-list"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Create Dictionary from Lists in Python - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Sometimes you may need to create dictionary from lists in Python. Here are different ways to convert lists to dictionaries.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create Dictionary from Lists in Python - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Sometimes you may need to create dictionary from lists in Python. Here are different ways to convert lists to dictionaries.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2025-03-27T06:28:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-03-27T07:38:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/create-dictionary-from-lists-python.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"258\" \/>\n\t<meta property=\"og:image:height\" content=\"171\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Create Dictionary from Lists in Python\",\"datePublished\":\"2025-03-27T06:28:05+00:00\",\"dateModified\":\"2025-03-27T07:38:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/\"},\"wordCount\":928,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/create-dictionary-from-lists-python.jpg?fit=258%2C171&ssl=1\",\"keywords\":[\"dict from list\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/\",\"url\":\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/\",\"name\":\"How to Create Dictionary from Lists in Python - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/create-dictionary-from-lists-python.jpg?fit=258%2C171&ssl=1\",\"datePublished\":\"2025-03-27T06:28:05+00:00\",\"dateModified\":\"2025-03-27T07:38:24+00:00\",\"author\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Sometimes you may need to create dictionary from lists in Python. Here are different ways to convert lists to dictionaries.\",\"breadcrumb\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/create-dictionary-from-lists-python.jpg?fit=258%2C171&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/create-dictionary-from-lists-python.jpg?fit=258%2C171&ssl=1\",\"width\":258,\"height\":171,\"caption\":\"create dictionary from lists in python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ubiq.co\/tech-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create Dictionary from Lists in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#website\",\"url\":\"https:\/\/ubiq.co\/tech-blog\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/\"],\"url\":\"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Create Dictionary from Lists in Python - Ubiq BI","description":"Sometimes you may need to create dictionary from lists in Python. Here are different ways to convert lists to dictionaries.","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:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/","og_locale":"en_US","og_type":"article","og_title":"How to Create Dictionary from Lists in Python - Ubiq BI","og_description":"Sometimes you may need to create dictionary from lists in Python. Here are different ways to convert lists to dictionaries.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2025-03-27T06:28:05+00:00","article_modified_time":"2025-03-27T07:38:24+00:00","og_image":[{"width":258,"height":171,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/create-dictionary-from-lists-python.jpg","type":"image\/jpeg"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Create Dictionary from Lists in Python","datePublished":"2025-03-27T06:28:05+00:00","dateModified":"2025-03-27T07:38:24+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/"},"wordCount":928,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/create-dictionary-from-lists-python.jpg?fit=258%2C171&ssl=1","keywords":["dict from list"],"articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/","name":"How to Create Dictionary from Lists in Python - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/create-dictionary-from-lists-python.jpg?fit=258%2C171&ssl=1","datePublished":"2025-03-27T06:28:05+00:00","dateModified":"2025-03-27T07:38:24+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Sometimes you may need to create dictionary from lists in Python. Here are different ways to convert lists to dictionaries.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/create-dictionary-from-lists-python.jpg?fit=258%2C171&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/create-dictionary-from-lists-python.jpg?fit=258%2C171&ssl=1","width":258,"height":171,"caption":"create dictionary from lists in python"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-create-dictionary-from-lists-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Create Dictionary from Lists in Python"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/create-dictionary-from-lists-python.jpg?fit=258%2C171&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-1WN","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/7489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=7489"}],"version-history":[{"count":31,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/7489\/revisions"}],"predecessor-version":[{"id":7522,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/7489\/revisions\/7522"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/7512"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=7489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=7489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=7489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}