How to create a set with all the elements contain in two sets in Python

2 Answers

0 votes
st1 = {"a", "b", "c", "x"}
st2 = {"a", "d", "e", "x", "f", "g"}

st = st1.intersection(st2)

print(st)


'''
run:

{'a', 'x'}

'''

 



answered Dec 11, 2017 by avibootz
0 votes
st1 = {"a", "b", "c", "x"}
st2 = {"a", "d", "e", "x", "f", "g"}

st = st1 & st2

print(st)


'''
run:

{'a', 'x'}

'''

 



answered Dec 11, 2017 by avibootz

Related questions

2 answers 256 views
1 answer 178 views
2 answers 180 views
1 answer 151 views
1 answer 175 views
3 answers 221 views
221 views asked Apr 24, 2021 by avibootz
...