We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I am giving explanation to my code. First I have used n=int(input()) => for the number of students are in the english news paper and then I am setting this to the set method which is a= set(input().split()) as the numbers need to be split and I am repeating the same procedure for french paper. Later, we need to do the union method and print the length.
n = int(input())
n= set(input().split())
b = int(input())
e= set(input().split())
r = n.union(e)
print(len(r))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Set .union() Operation
You are viewing a single comment's thread. Return to all comments →
I am giving explanation to my code. First I have used n=int(input()) => for the number of students are in the english news paper and then I am setting this to the set method which is a= set(input().split()) as the numbers need to be split and I am repeating the same procedure for french paper. Later, we need to do the union method and print the length. n = int(input()) n= set(input().split()) b = int(input()) e= set(input().split()) r = n.union(e) print(len(r))