1/22/2014

(Python study) about set variable (example source code)

a = {1, 2, 3}
print(a)

b = {3, 4, 5}

print( a.union(b) )
#{1, 2, 3, 4, 5}

print( a.intersection(b) )
#{3}

print( a-b )
print( a|b )
print( a&b )
#{1, 2}
#{1, 2, 3, 4, 5}
#{3}




No comments:

Post a Comment