def unique(l):
"""Filters duplicates of iterable.
Create a new list from l with duplicate entries removed,
while preserving the original order.
Parameters
----------
l : iterable
Input iterable to filter of duplicates.
Returns
-------
list
A list of elements of `l` without duplicates and in the same order.
"""
new_list = []
seen = set()
for el in l:
if el not in seen:
new_list.append(el)
seen.add(el)
return new_list
评论列表
文章目录