collection data types difference symmetric difference we can use the membership operatorinto see whether particular key is in dictionaryfor examplex in and we can use the intersection operator to see which keys from given set are in dictionary for exampled {fromkeys("abcd" set("acx"matches keys( ={' ' ' ' ' ' ' ' ={' '' '' 'matches ={' '' 'note that in the snippet' comments we have used alphabetical order--this is purely for ease of reading since dictionaries and sets are unordered dictionaries are often used to keep counts of unique items one such example of this is counting the number of occurrences of each unique word in file here is complete program (uniquewords pythat lists every word and the number of times it occurs in alphabetical order for all the files listed on the command lineimport string import sys words {strip string whitespace string punctuation string digits "\"'for filename in sys argv[ :]for line in open(filename)for word in line lower(split()word word strip(stripif len(word words[wordwords get(word for word in sorted(words)print("'{ }occurs { timesformat(wordwords[word])we begin by creating an empty dictionary called words then we create string that contains all those characters that we want to ignoreby concatenating some useful strings provided by the string module we iterate over each filename given on the command lineand over each line in each file see the sidebar "reading and writing text files for an explanation of the open(function we don' specify an encoding (because we don' know what each file' encoding will be)so we let python open each file using the default local encoding we split each lowercased line into wordsand then strip off the characters that we want to ignore from both ends of each word if the resultant word is at least three characters long we need to update the dictionary we cannot use the syntax words[word+ because this will raise keyerror exception the first time new word is encountered--after allwe can' increment the value of an item that does not yet exist in the dictionary so we use