Never been to DZone Snippets before?

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

play with set (new python 2.4 module) (See related posts)

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

You need to create an account or log in to post comments to this site.


Click here to browse all 5137 code snippets

Related Posts