This function will receive a list of elements with duplicate elements, this function should remove the duplicate elements in the list and return a list without duplicate elements. The elements in the returned list must be in the same order that they were found in the list the function received. A duplicate element is an element found more than one time in the specified list.
PYTHON
def remove_duplicate(A): #define function
B=[] #intialize new list B
for element in A: #iterate through each element of A
if element not in B: #check element exist in new element B if not then append it
B.append(element)
print("New list: ",B)
A=[1,1,2,3,3,4,2,6,7,6,8,"A","B","A"]
print("Original list: ",A)
remove_duplicate(A)
Get Answers For Free
Most questions answered within 1 hours.