How to remove duplicates from three different lists? code example
Example 1: python remove repeated elements from list
# ----- Create a list with no repeating elements ------ #
mylist = [67, 7, 89, 7, 2, 7]
newlist = []
for i in mylist:
if i not in newlist:
newlist.append(i)
Example 2: remove duplicates from a list of lists python
k = [[1, 2], [4], [5, 6, 2], [1, 2], [3], [4]]
new_k = []
for elem in k:
if elem not in new_k:
new_k.append(elem)
k = new_k
print k
# prints [[1, 2], [4], [5, 6, 2], [3]]