Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

set symmetric difference

  • set
  • symmetric_difference
english = set(['door', 'car', 'lunar', 'era'])
spanish = set(['era', 'lunar', 'hola'])

diff = english.symmetric_difference(spanish)
print('symmetric_difference: ', diff)
  • Symmetric difference contains all the elements in either one of the sets, but not in both. "the ears of the elephant".

Output:

symmetric_difference:  {'door', 'hola', 'car'}