DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Play With Set (new Python 2.4 Module)

09.07.2005
| 3720 views |
  • submit to reddit
        
a = set("ABC")
b = set("CDE")

print "A:",a
print "B:",b
print "Intersection:\t",a & b
print "Union:\t\t",a | b
print "Diff a-b:\t\t",a - b
print "Diff b-a:\t\t",b - a
print "Exclusive:\t\t",a ^ b