Advertisement
here2share

# list_differences.py

May 26th, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. # list_differences.py
  2.  
  3. color_list1 = ["red","green","blue","purple","yellow","violet","white","cyan",
  4.    "magenta","turquoise","black","lightblue","grey","lightgrey","darkgrey",
  5.    "lightgreen","teal","pink","darkblue","darkred","darkgreen","orchid","beige"]
  6.  
  7. color_list2 = ["red","green","blue","purple","yellow","orchid","grey","white",
  8.    "cyan","turquoise","limegreen","lightblue","lightgrey","darkgrey","violet",
  9.    "lightgreen","tan","darkblue","darkred","darkgreen","pink"]
  10.  
  11. print "color_list1 =", color_list1
  12. print "-"*70  # 70 dashes
  13. print "color_list2 =", color_list2
  14. print "-"*70
  15.  
  16. # convert lists to sets
  17. color_set1 = set(color_list1)
  18. color_set2 = set(color_list2)
  19. print "These are the colors of color_list1 that are not in color_list2:"
  20. print color_set1 - color_set2
  21. print "-"*70
  22. print "These are the colors of color_list2 that are not in color_list1:"
  23. print color_set2 - color_set1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement