Answers for "python set intersection"

0

python set intersection

both = {'a', 'A', 'b', 'B'}
some = {'a', 'b', 'c'}
result1 = both & some
# result: {'a', 'b'}
result2 = both.intersection(some)

print(result1 == result2)
# True
Posted by: Guest on March-28-2021
0

Set .intersection() operation solution in python3

# Enter your code here. Read input from STDIN. Print output to STDOUT
num1, st1, num2, st2 = (set(input().split()) for i in range(4))
print(len(st1.intersection(st2)))
Posted by: Guest on April-22-2021

Python Answers by Framework

Browse Popular Code Answers by Language