Removing Duplicates from a List in Python

  • Share this:

Code introduction


This function is used to remove duplicates from a list and return a new list without any duplicates.


Technology Stack : os, sys, time, json, re

Code Type : Function

Code Difficulty : Intermediate


                
                    
import os
import sys
import time
import json
import re

def remove_duplicates_from_list(input_list):
    seen = set()
    result = []
    for item in input_list:
        if item not in seen:
            seen.add(item)
            result.append(item)
    return result                
              
Tags: