Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # set_operators.py
- # Demonstrating set operations on unique letters from two strings
- a = set('abracadabra')
- b = set('alacazam')
- print a # unique letters in a {'a', 'r', 'b', 'c', 'd'}
- print a - b # letters in a but not in b {'r', 'd', 'b'}
- print a | b # letters in either a or b {'a', 'c', 'r', 'd', 'b', 'm', 'z', 'l'}
- print a & b # letters in both a and b {'a', 'c'}
- print a ^ b # letters in a or b but not both {'r', 'd', 'b', 'm', 'z', 'l'}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement