Set Mutations

  • + 10 comments

    Python 3

    if __name__ == '__main__':
        (_, A) = (int(input()),set(map(int, input().split())))
        B = int(input())
        for _ in range(B):
            (command, newSet) = (input().split()[0],set(map(int, input().split())))
            getattr(A, command)(newSet)
    
        print (sum(A))