Programmingempire

The following code shows an example to Remove Duplicate Elements from a List in Python. At first, we create a list having duplicate elements. After that, we create another list that is empty. It will contain the elements after removing duplicates. Further, we iterate over all elements in the list. In order to remove the duplicate elements, we compare the ith element of the original list with elements in the new list. If the element is not there, we append it to the new list.

mylist=[12,1,3,54,12,12,3,3,3,5,6,3,54,3,2,54]
print('list elements: ')
for i in range(len(mylist)):
   print(mylist[i])
   

print('Removing duplicates from the list...')
list1=[]
for i in range(len(mylist)):
   f=False
   for j in range(len(list1)):
      if list1[j]==mylist[i]:
        f=True
   if f==False:
     list1.append(mylist[i])
         
for i in range(len(list1)):
   print(list1[i]) 

Output

The Output of the Program to Remove Duplicate Elements from a List in Python
The Output of the Program to Remove Duplicate Elements from a List in Python

Further Reading

Deep Learning Tutorial

Text Summarization Techniques

How to Implement Inheritance in Python

Find Prime Numbers in Given Range in Python

Running Instructions in an Interactive Interpreter in Python

Deep Learning Practice Exercise

Python Practice Exercise

Deep Learning Methods for Object Detection

Understanding YOLO Algorithm

What is Image Segmentation?

ImageNet and its Applications

Image Contrast Enhancement using Histogram Equalization

Transfer Learning and its Applications

Examples of OpenCV Library in Python

Examples of Tuples in Python

Python List Practice Exercise

Understanding Blockchain Concepts

Edge Detection Using OpenCV

Predicting with Time Series

Example of Multi-layer Perceptron Classifier in Python

Measuring Performance of Classification using Confusion Matrix

Artificial Neural Network (ANN) Model using Scikit-Learn

Popular Machine Learning Algorithms for Prediction

Long Short Term Memory – An Artificial Recurrent Neural Network Architecture

Python Project Ideas for Undergraduate Students

Creating Basic Charts using Plotly

Visualizing Regression Models with lmplot() and residplot() in Seaborn

Data Visualization with Pandas

A Brief Introduction of Pandas Library in Python

A Brief Tutorial on NumPy in Python

programmingempire