Bhanu and Soham are good friends. Yesterday they have given an exam in which there were given two different set of questions to solve. Bhanu was given set A and Soham was given set B. After examination they want to cross check their answers. For this they need to identify common questions in their sets. Write a python function Check_Common(A, B) which takes two sets A and B as a input and return true if any common question found otherwise return false.
Example-1
Example-2
Input:
{1, 2, 3, 4}
{4, 5, 6, 7}
Output:
True
Input:
{1, 2, 3, 4}
{5, 6, 7, 8}
Output:
False
def Check_Common(A, B):
for a in A:
if a in B:
return True
return False
def main():
print('Example-1')
A = {1, 2, 3, 4}
B = {4, 5, 6, 7}
print('A =', A)
print('B =', B)
print(Check_Common(A, B))
print()
print('Example-2')
A = {1, 2, 3, 4}
B = {5, 6, 7, 8}
print('A =', A)
print('B =', B)
print(Check_Common(A, B))
if __name__ == '__main__':
main()
Comments
Leave a comment