- Related Questions & Answers
- Java program to find missing and additional values in two lists
- C# program to find additional values in two lists
- Python program to find Intersection of two lists?
- C# program to find common values from two or more Lists
- Python program to find Union of two or more Lists?
- Program to find minimum difference between two elements from two lists in Python
- Program to find union of two given linked lists in Python
- C# program to find Intersection of two lists
- How to compare two DataFrames in Python Pandas with missing values
- Program to find median of two sorted lists in C++
- Python program to list the difference between two lists.
- C# program to find Union of two or more Lists
- Dividing two lists in Python
- Program to find first positive missing integer in range in Python
- Python program to split the even and odd elements into two different lists.

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In set theory, the complement of a set A refers to elements not in A. the relative complement of A with respect to a set B, also termed the difference of Sets A and B. We just apply this principle here. Python has difference function.

Step 1 : first we create two user input list. A & B Step 2 : Insert A and B to a set. Step 3 : for finding the missing values of first list we apply difference function, difference of B from A. Step 4 : for finding the Additional values of first list we apply difference function, difference of A from B. Step 5 : Same procedure apply for Second list also.

#To find the missing and additional elements A=list() B=list() n1=int(input("Enter the size of the First List ::")) n2=int(input("Enter the size of the second List ::")) print("Enter the Element of first List ::") for i in range(int(n1)): k=int(input("")) A.append(k) print("Enter the Element of second List ::") for j in range(int(n2)): k1=int(input("")) B.append(k1) # prints the missing and additional elements in first list print("Missing values in first list:", (set(B).difference(A))) print("Additional values in first list:", (set(A).difference(B))) # prints the missing and additional elements in second list print("Missing values in second list:", (set(A).difference(B))) print("Additional values in second list:", (set(B).difference(A)))

Enter the size of the First List :: 6 Enter the size of the second List :: 5 Enter the Element of first List :: 1 2 3 4 5 6 Enter the Element of second List :: 4 5 6 7 8 Missing values in first list: {7, 8} Additional values in first list: {1, 2, 3} Missing values in second list: {1, 2, 3} Additional values in second list: {7, 8}

Advertisements