Removing duplicate element form the list in python is easy unlike c program.Python includes datatype for sets.A set is an unordered collection of elements without duplicate entries.We can just make set of the list and again make list of that set to get the output. Program I : inputlist = [22,33,33,44,55,55,55,66,66] outputlist = list(set(inputlist)) print outputlist Just three lines of code and you will get the list without any duplicate elements.There are several other technique also for writing program to find the distinct element in the list without using set. Program II : inputlist = [22,33,33,44,55,55,55,66,66] outputlist = [] for element in inputlist: if element not in outputlist: outputlist.append(element) print outputlist You can use http://www.codeskulptor.org/ to run the python programs online.
Data Engineering interview preparation with practical insights on SQL, coding, data pipelines, cloud platforms (GCP, AWS), Snowflake, dbt, Fivetran, and AI-driven data systems. This Blog is based on real-world and personal experiences.