Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created Jun 15, 2020
Embed
What would you like to do?
s1={1,2,3,4,5}
s2={4,5,6,7,8}
#union by using | operator
s3=s1|s2
print (s3) #Output:{1, 2, 3, 4, 5, 6, 7, 8}
# by using union() method
s4=s1.union(s2)
print (s4) #Output:{1, 2, 3, 4, 5, 6, 7, 8}
#intersection using & operator
s5=s1&s2
print (s5) #Output:{4, 5}
s6=s1.intersection(s2)
print (s6) #Output: {4, 5}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment