xxxxxxxxxx
both = {'a', 'A', 'b', 'B'}
some = {'a', 'b', 'c'}
result1 = both & some
# result: {'a', 'b'}
result2 = both.intersection(some)
print(result1 == result2)
# True
xxxxxxxxxx
set_1 = {1, 2, 3, 4, 5}
set_2 = {3, 4, 5, 6}
# Method 1
intersection_1 = set_1 & set_2 # {3,4,5}
# Method 2
intersection_2 = set_1.intersection(set_2) # {3,4,5}
xxxxxxxxxx
# The intersection() function can be used to create a new set containing the shared
# values from one set with another
mySet = {1, 2, 3, 4}
mySet2 = {3, 4, 5, 6}
mySet3 = mySet.intersection(mySet2)
print(mySet3)
# Output:
# {3, 4}
xxxxxxxxxx
set1 = {1, 2, 3, 4}
set2 = {3, 4, 5, 6}
intersection = set1.intersection(set2)
print(intersection)
xxxxxxxxxx
firstSet = {2, 3, 4, 5}
secondSet = {1, 3, 5, 7}
print(firstSet & secondSet)
# {3, 5}
xxxxxxxxxx
set1 = {1, 2, 3, 4, 5}
set2 = {4, 5, 6, 7, 8}
# Using intersection() method
intersection_result = set1.intersection(set2)
print(intersection_result) # Output: {4, 5}
# Using `&` operator
intersection_result = set1 & set2
print(intersection_result) # Output: {4, 5}
xxxxxxxxxx
valid = set(['yellow', 'red', 'blue', 'green', 'black'])
input_set = set(['red', 'brown'])
print(input_set.intersection(valid))
# Output: set(['red'])
xxxxxxxxxx
# 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)))