Q:

Write a Python program to find the difference between two list including duplicate elements

0

 Write a Python program to find the difference between two list including duplicate elements.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def list_difference(l1,l2):
    result = list(l1)
    for el in l2:
        result.remove(el)
    return result
l1 = [1,1,2,3,3,4,4,5,6,7]
l2 = [1,1,2,4,5,6]

print("Original lists:")
print(l1)
print(l2)
print("\nDifference between two said list including duplicate elements):")
print(list_difference(l1,l2))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now