In this program, we will take two lists as input. Find the difference between two lists with the help of the below-given steps.
Difference between two lists:
Steps to solve the program
- Take two lists as input.
- Print the elements from the list1 who are not in list2.
- Use for loop and an if statement for this purpose.
#Input list
list1 = [34,55,12,89,44,67]
list2 = [55,89,34]
for value in list1:
if value not in list2:
#Printing output
print(value, end=" ")
Output :
12 44 67
Related Articles
Python program to reverse each element of the list.
Python program to combine two list elements as a sublist in a list.
Python program to get keys and values from the list of dictionaries.
Python program to get all the unique numbers in the list.
Python program to convert a string into a list.
Python program to replace the last and the first number of the list with the word.