Created
October 17, 2019 17:05
-
-
Save fabiosoft/a5e4e0bf59bbab1eee768d6d00ff3dc6 to your computer and use it in GitHub Desktop.
Array list diffing in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python program to find the missing | |
# and additional elements | |
# source: https://www.geeksforgeeks.org/python-find-missing-additional-values-two-lists/ | |
# examples of lists | |
list1 = [1, 2, 3, 4, 5, 6] | |
list2 = [4, 5, 6, 7, 8] | |
# prints the missing and additional elements in list2 | |
print("Missing values in second list:", (set(list1).difference(list2))) | |
print("Additional values in second list:", (set(list2).difference(list1))) | |
# prints the missing and additional elements in list1 | |
print("Missing values in first list:", (set(list2).difference(list1))) | |
print("Additional values in first list:", (set(list1).difference(list2))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment