Set operations on unique letters from two words : Set Declaration : Data Structure PYTHON examples


PYTHON examples » Data Structure » Set Declaration »

 

Set operations on unique letters from two words


Set operations on unique letters from two words


a = set('abracadabra')
b = set('alacazam')
print a                                  # unique letters in a
set(['a''r''b''c''d'])
print a - b                              # letters in a but not in b

print a | b                              # letters in either a or b

print a & b                              # letters in both a and b

print a ^ b                              # letters in a or b but not both

           
       



    Related Scripts with Example Source Code in same category :

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Data Structure
» Set Declaration