Set .union() Operation

Sort by

recency

|

773 Discussions

|

  • + 0 comments
    def stud_newspaper(a,b):
        return len(a.union(b))
    
    
    
    if __name__ == '__main__':
        n = int(input())
        eng = set(map(int, input().split()))
        b = int(input())
        fre = set(map(int, input().split()))
        print(stud_newspaper(eng, fre))
    
  • + 0 comments
    ll=[]
    for _ in range(2):
        n = int(input())
        n_s = set(map(int,input().split()))
        ll.append(n_s)
    
    print(len(ll[0].union(ll[1])))
    
  • [deleted]Challenge Author
    + 0 comments

    For Python3

    n = int(input())
    english = set(input().split())
    b = int(input())
    french = input().split()
    
    print(len(english.union(french)))
    
  • + 0 comments

    n1 = int(input()) n1 = set(input().split())

    n2 = int(input()) n2 = set(input().split())

    print(len(n1.union(n2)))

  • + 0 comments

    n = int(input())
    set1 = set(map(int, input().split()))
    s = int(input())
    set2 = set(map(int, input().split()))
    print(len(set1 | set2))