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
Further Reading
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
Deep Learning Methods for Object Detection
Image Contrast Enhancement using Histogram Equalization
Transfer Learning and its Applications
Examples of OpenCV Library in Python
Understanding Blockchain Concepts
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