Set .union() Operation

Sort by

recency

|

778 Discussions

|

  • + 0 comments

    a = int(input()) b = set(map(int, input().split())) c = int(input()) d = set(map(int, input().split()))

    e = b.union(d) count=0 for i in range(len(e)): count=count+1

    print(count)

  • + 0 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))

  • + 0 comments

    a=int(input()) n=set(map(int,input().split())) b=int(input()) e=set(map(int,input().split())) r=n.union(e) print(len(r))

  • + 0 comments

    a=int(input()) n=set(map(int,input().split())) b=int(input()) e=set(map(int,input().split())) r=n.union(e) print(len(r))

  • + 0 comments

    n=int(input()) a=set(input().split()) n1=int(input()) a1=set(input().split()) print(len(a | a1))