Extracting Unique Elements from a List

  • Share this:

Code introduction


Extracts all unique elements from a list and returns a set containing these unique elements.


Technology Stack : 集合(set)

Code Type : Function

Code Difficulty : Intermediate


                
                    
def get_unique_element(lst):
    seen = set()
    for item in lst:
        if item not in seen:
            seen.add(item)
    return seen                
              
Tags: