{"id":7456,"date":"2025-03-26T06:08:15","date_gmt":"2025-03-26T06:08:15","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=7456"},"modified":"2025-03-26T07:21:10","modified_gmt":"2025-03-26T07:21:10","slug":"how-to-remove-duplicates-from-list-in-python","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/","title":{"rendered":"How to Remove Duplicates from List in Python"},"content":{"rendered":"\n<p>Python developers commonly use lists to store data. Lists are versatile data structures that allow you to store different data types in a compact manner. Often lists contain duplicate data. Sometimes, software developers need to remove duplicates from list for their programs. Otherwise, it may lead to undesirable results. There are several ways to delete duplicates from Python list. In this article, we will learn how to remove duplicates from list in Python.<\/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-remove-duplicates-from-list-in-python\/#Why_Remove_duplicates_from_list_in_Python\" >Why Remove duplicates from list in Python<\/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-remove-duplicates-from-list-in-python\/#How_to_Remove_Duplicates_from_List_in_Python\" >How to Remove Duplicates from List 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-remove-duplicates-from-list-in-python\/#1_Using_Set\" >1. Using Set<\/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-remove-duplicates-from-list-in-python\/#2_Using_fromkeys_function\" >2. Using fromkeys function<\/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-remove-duplicates-from-list-in-python\/#3_Using_List_Comprehension\" >3. Using List Comprehension<\/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-remove-duplicates-from-list-in-python\/#4_Using_Unpacking_Operator\" >4. Using Unpacking Operator<\/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-remove-duplicates-from-list-in-python\/#5_In_Numpy\" >5. In Numpy<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/#6_In_Pandas\" >6. In Pandas<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/#7_Using_for_loop\" >7. Using for loop<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/#For_Strings\" >For Strings<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Remove_duplicates_from_list_in_Python\"><\/span>Why Remove duplicates from list in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Sometimes a list may contain duplicate values. If your program requires list with unique items, then such lists with duplicate values may cause your program to give error or wrong result. Therefore, depending on the use case, it is important to remove duplicates from list in Python.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Remove_Duplicates_from_List_in_Python\"><\/span>How to Remove Duplicates from List in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let us say you have the following list with duplicate values in it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">data = [1, 2, 3, 3, 4, 4, 5]<\/pre>\n\n\n\n<p>Here are the different ways to remove duplicates from list in Python. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Using_Set\"><\/span>1. Using Set<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>By definition, a set can contain only unique values. Python allows you to create sets or tuples using set() constructor. You can use this function to remove duplicates from a list. Set() function accepts one input, which can be a list of values. If we provide a list with duplicate values to set() function, then it will return a set with unique values. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">data1 = set(data) # output is (1, 2, 3, 4, 5)<\/pre>\n\n\n\n<p>We can pass this set into a list constructor, which returns a list of items, present in the input set.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">list(data1) # output is [1, 2, 3, 4, 5]<\/pre>\n\n\n\n<p>Combining the two, we get the following.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">new_data = list(set(data)) # output is [1, 2, 3, 4, 5]<\/pre>\n\n\n\n<p>However, please note, using set may alter the order of items present in the output.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Using_fromkeys_function\"><\/span>2. Using fromkeys function<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you want to preserve the order of items in final list, then you can use fromkeys() method present in OrderedDict library.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from collections import OrderedDict<br>data = [1, 2, 3, 3, 4, 4, 5]<br>print(list(OrderedDict.fromkeys(data))) # output is [1, 2, 3, 4, 5]<\/pre>\n\n\n\n<p>The fromkeys function generates a dictionary from a list of keys and values. If no values are specified, then all the values of the result dict will be None. Since a dictionary cannot have duplicate keys, all the duplicate list items are ignored. When we call list() constructor on this dict, it will construct the list using only the keys of dict.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">OrderedDict.fromkeys(data) # output is {1: None, 2: None, 3: None, 4: None, 5: None}<br>list(OrderedDict.fromkeys(data)) # output is [1, 2, 3, 4, 5]<\/pre>\n\n\n\n<p>If you are using Python >=3.7, then the dictionary constructor will preserve insertion order of items. In this case, you can directly use the plain old dict module for this purpose.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">print(list(dict.fromkeys(data))) # output is [1, 2, 3, 4, 5]<\/pre>\n\n\n\n<p>In the above code, we directly call dict.fromkeys() on our data list. We do not need to import any module. However, please note, if you use Python &lt; 3.7, then the dictionary created using our <em>data<\/em> list may not preserve the order of elements.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Using_List_Comprehension\"><\/span>3. Using List Comprehension<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>List comprehensions provide a compact way to iterate through a list and perform a given task. Here is an example to illustrate it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">data = [1, 2, 3, 3, 4, 4, 5]<br>result = []<br>[result.append(val) for val in data if val not in result]<br>print(result)  # output is [1, 2, 3, 4, 5]<\/pre>\n\n\n\n<p>In the above code, we define an empty list <em>result<\/em> to store the new list without duplicates. We use a list comprehension to iterate through all items of list. In each iteration, we check if the item is present in the new list or not. If not, then we append it to the new list. <\/p>\n\n\n\n<p>The benefit of this solution is that it preserves the order of items from the original list. Also, you can customize the list comprehension to exclude certain items if you want.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Using_Unpacking_Operator\"><\/span>4. Using Unpacking Operator<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can also use unpacking operator (*) to first unpack the list items into a set, and then use it again, to unpack\/expand the set items to a list. When the original list is converted into a set, its duplicates are automatically dropped since a set cannot contain duplicates.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">data = [1, 2, 3, 3, 4, 4, 5]<br>result =  [*{*data}]<br>print(result) # output is [1, 2, 3, 4, 5]<\/pre>\n\n\n\n<p>This is a super compact way of removing duplicates from a list. Please note, since we convert list into set, the order of its items may not be preserved. If you are not particular about the order of items in the final list, then you can use this solution.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_In_Numpy\"><\/span>5. In Numpy<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Numpy is a powerful Python module that allows you to easily process data and numbers. It provides unique() function to easily remove duplicates from a list. Here is an example.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import numpy as np<br>data = [5, 4, 4, 1, 2, 3, 3]<br>result =  np.unique(data).tolist()<br>print(result)<\/pre>\n\n\n\n<p>In the above code, we first import Numpy module. Then we call unique() function on our original list <em>data<\/em>. This will remove all the duplicates from the list. It returns a numpy.ndarray. Next, we call tolist() function to convert the result of unique() function to a list. Please note, it sorts the values so you will see the output to be unique but sorted items. Here is the output.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[1, 2, 3, 4, 5]<\/pre>\n\n\n\n<p>This is very useful if you are using Numpy in your program.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"6_In_Pandas\"><\/span>6. In Pandas<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Pandas is a popular Python library that allows you to store and analyze data in a tabular manner, using rows and columns. Like Numpy library, it also provides unique() and tolist() functions to remove duplicates from a list, and convert the result back into list respectively.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import pandas as pd<br>data = [5, 4, 4, 1, 2, 3, 3]<br>result =  pd.unique(data).tolist()<br>print(result) # output is [5, 4, 1, 2, 3]<\/pre>\n\n\n\n<p>As you can see, unlike Numpy, the unique() function in Pandas does not sort the result but preserves the order of items in the original list. If you are using Pandas library in your code, then this is a convenient method.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"7_Using_for_loop\"><\/span>7. Using for loop<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This is perhaps the most basic way to remove duplicates in a list. First, we create an empty list to store the items without duplicates. We simply loop through the items of list. In each iteration, we check if the item is present in the new list. If not, then we append the item into the list.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">data = [5, 4, 4, 1, 2, 3, 3]<br>result = []<br><br>for val in data:<br>    if val not in result:<br>        result.append(val)<br>print(result) # output is [5, 4, 1, 2, 3]<\/pre>\n\n\n\n<p>Although this is the most verbose solution among all, it provides tremendous flexibility and customization. For example, here is an example to exclude item=4 from de-duplication.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">data = [5, 4, 4, 1, 2, 3, 3]<br>result = []<br><br>for val in data:<br>    if val not in result or val==4:<br>        result.append(val)<br>print(result)  # output is [5, 4, 4, 1, 2, 3]<\/pre>\n\n\n\n<p>Secondly, it also preserves the order of items in the original list.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"For_Strings\"><\/span>For Strings<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>So far, we have seen how to remove duplicates in Python list. But these solutions can also be applied to strings. The result in each case, we will be a list of unique characters from the string. Here is an example to demonstrate it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">data = \"good morning\"<br><br>print(list(set(data)))    # output is [' ', 'n', 'i', 'g', 'o', 'r', 'd', 'm']<br>print(list(dict.fromkeys(data)))  # output is ['g', 'o', 'd', ' ', 'm', 'r', 'n', 'i']<br>result=[]<br>[result.append(val) for val in data if val not in result]<br>print(result)   # output is ['g', 'o', 'd', ' ', 'm', 'r', 'n', 'i']<br><br>print([*{*data}])  # output is [' ', 'n', 'i', 'g', 'o', 'r', 'd', 'm']<br><\/pre>\n\n\n\n<p>The unique() function in Numpy and Pandas cannot be used for strings.<\/p>\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 many different ways to remove duplicates in Python list. If you are not particular about the order of items, then you can use set() function since it contains less overhead. If you need to preserve order of items, then you can use OrderedDict.fromkeys or dict.fromkeys function. If you do not want a direct list of unique items but need to customize the deduplication, then you can use list comprehension or plain for-loop. If you are already using Numpy or Pandas library in your program, then you can use their unique() and tolist() functions to remove duplicates.<\/p>\n\n\n\n<p>Also read:<\/p>\n\n\n\n<p><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 in Python<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-select-multiple-columns-in-pandas-dataframe\/\">How to Select Multiple Columns in Pandas Dataframe<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you may need to remove duplicates from Python list. Here are different ways to delete duplicate in Python List.<\/p>\n","protected":false},"author":1,"featured_media":7478,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[301],"tags":[362],"class_list":["post-7456","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-remove-duplicates"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Remove Duplicates from List in Python - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Sometimes you may need to remove duplicates from Python list. Here are different ways to delete duplicate in Python List.\" \/>\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-remove-duplicates-from-list-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 Remove Duplicates from List in Python - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Sometimes you may need to remove duplicates from Python list. Here are different ways to delete duplicate in Python List.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-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-26T06:08:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-03-26T07:21:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/remove-duplicates-from-python-list.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"285\" \/>\n\t<meta property=\"og:image:height\" content=\"190\" \/>\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=\"6 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-remove-duplicates-from-list-in-python\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-duplicates-from-list-in-python\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Remove Duplicates from List in Python\",\"datePublished\":\"2025-03-26T06:08:15+00:00\",\"dateModified\":\"2025-03-26T07:21:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-duplicates-from-list-in-python\\\/\"},\"wordCount\":1140,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-duplicates-from-list-in-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/remove-duplicates-from-python-list.jpg?fit=285%2C190&ssl=1\",\"keywords\":[\"remove duplicates\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-duplicates-from-list-in-python\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-duplicates-from-list-in-python\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-duplicates-from-list-in-python\\\/\",\"name\":\"How to Remove Duplicates from List in Python - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-duplicates-from-list-in-python\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-duplicates-from-list-in-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/remove-duplicates-from-python-list.jpg?fit=285%2C190&ssl=1\",\"datePublished\":\"2025-03-26T06:08:15+00:00\",\"dateModified\":\"2025-03-26T07:21:10+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Sometimes you may need to remove duplicates from Python list. Here are different ways to delete duplicate in Python List.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-duplicates-from-list-in-python\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-duplicates-from-list-in-python\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-duplicates-from-list-in-python\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/remove-duplicates-from-python-list.jpg?fit=285%2C190&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/remove-duplicates-from-python-list.jpg?fit=285%2C190&ssl=1\",\"width\":285,\"height\":190,\"caption\":\"remove duplicates from python list\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-duplicates-from-list-in-python\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Remove Duplicates from List 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 Remove Duplicates from List in Python - Ubiq BI","description":"Sometimes you may need to remove duplicates from Python list. Here are different ways to delete duplicate in Python List.","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-remove-duplicates-from-list-in-python\/","og_locale":"en_US","og_type":"article","og_title":"How to Remove Duplicates from List in Python - Ubiq BI","og_description":"Sometimes you may need to remove duplicates from Python list. Here are different ways to delete duplicate in Python List.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2025-03-26T06:08:15+00:00","article_modified_time":"2025-03-26T07:21:10+00:00","og_image":[{"width":285,"height":190,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/remove-duplicates-from-python-list.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":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Remove Duplicates from List in Python","datePublished":"2025-03-26T06:08:15+00:00","dateModified":"2025-03-26T07:21:10+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/"},"wordCount":1140,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/remove-duplicates-from-python-list.jpg?fit=285%2C190&ssl=1","keywords":["remove duplicates"],"articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/","name":"How to Remove Duplicates from List in Python - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/remove-duplicates-from-python-list.jpg?fit=285%2C190&ssl=1","datePublished":"2025-03-26T06:08:15+00:00","dateModified":"2025-03-26T07:21:10+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Sometimes you may need to remove duplicates from Python list. Here are different ways to delete duplicate in Python List.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/remove-duplicates-from-python-list.jpg?fit=285%2C190&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/03\/remove-duplicates-from-python-list.jpg?fit=285%2C190&ssl=1","width":285,"height":190,"caption":"remove duplicates from python list"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-duplicates-from-list-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Remove Duplicates from List 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\/remove-duplicates-from-python-list.jpg?fit=285%2C190&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-1Wg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/7456","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=7456"}],"version-history":[{"count":31,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/7456\/revisions"}],"predecessor-version":[{"id":7488,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/7456\/revisions\/7488"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/7478"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=7456"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=7456"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=7456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}