Home > Uncategorized > Computing a Symmetrical Difference in sets and lists.

Computing a Symmetrical Difference in sets and lists.

June 18th, 2009

Symmetrical difference calculates the difference of not whats in the just one list. It calculates the items that are not common in both lists!

list1=['donkey','balls']
list2=['donkey','scrotom']
set1=set(list1)
set2=set(list2)
print set1

set(['donkey', 'balls'])

print set2

set(['donkey', 'scrotom'])

symdiff = set1 ^ set2
symdiff

set(['balls', 'scrotom'])

Uncategorized

  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.