Extract Unique Elements from List

  • Share this:

Code introduction


This function takes a list as an argument and returns a new list containing only the unique elements from the original list.


Technology Stack : set

Code Type : Function

Code Difficulty :


                
                    
def unique_list(items):
    """
    返回一个包含所有唯一元素的列表,使用集合来去重,然后转换回列表。
    """
    return list(set(items))                
              
Tags: