Basic Programs

If Else Programs

While loop Programs

For loop Programs

List Programs


Python Program to Find the Difference Between Two Lists


This example shows, how to find the difference between the two given lists. We have two lists having the same type of elements and finding the difference between the given lists.

Example.py
# a - first list of the integers
# b - second list of the integers
a = [78, 68, 58, 28, 18]
b = [78, 68, 58, 38, 48]

# printing lists 
print("a:", a)
print("b:", b)

# finding and printing differences 
# of the lists
print("Difference elements:")
print(list(set(a) - set(b)))

Output

a: [78, 68, 58, 28, 18]
b: [78, 68, 58, 38, 48]
Difference elements:
[18, 28]

Prev Next