Set in python

technical talkiess
0

 s = set()


# if you want to add some value in the list then you can use the following code 
s.add(1)
# set is store only the unique value in the set .... if you want to add duplicate value then it's not added 
s.add(2)

# print(s)
# min valu 
# print(min(s))
# max value
# print(max(s))
l = [1,2,3,4,5,6,7,8]
# new set bana deta hai 

s2 = s.union(l)
# intersection is return the matching element of the both list

# s2 = s.intersection(l)
# remove any element in the set 
# s2.remove(2)

print(s.isdisjoint(s2))
Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)