In this Set .union() operation problem we need to develop a python program that can read four lines of input and then we need to print the total number of students who have at least one subscription on the output screen.
Problem solution in Python 2 programming.
eng = set() fre = set() n = raw_input() for i in raw_input().split(' '): eng.add(i) m = raw_input() for i in raw_input().split(' '): fre.add(i) sol = eng.union(fre) print len(sol)
Problem solution in Python 3 programming.
# Enter your code here. Read input from STDIN. Print output to STDOUT n = int(input()) l = list(input().split()) m = int(input()) k = list(input().split()) s1 = set(l) s2 = set(k) print(len(s1.union(s2)))
Problem solution in pypy programming.
# Enter your code here. Read input from STDIN. Print output to STDOUT n = input() s = set(map(int, raw_input().split())) m = input() t = set(map(int, raw_input().split())) print len(s.union(t))
Problem solution in pypy3 programming.
n = int(input()) A = set(map(int, input().split())) m = int(input()) B = set(map(int, input().split())) ans = A.union(B) print(len(ans))