LinkedIn Reddit icon

Dunder Doc

by Valdir Stumm Jr

Blog Posts

Drop Duplicates from a List in Order

Let’s say you have a list containing all the URLs extracted from a web page and you want to get rid of duplicate URLs. The most common way of achieving that might be building a set from that list, given that such operation automatically drops the duplicates. Something like: >>> urls = [ '', '', '', '' ] >>> set(urls) {'', '', ''} The problem is that we just lost the original order of the list.