Set Mutations

  • + 1 comment

    Can someone help me debug this? I'm getting EOFError for the input of command.

    # Enter your code here. Read input from STDIN. Print output to STDOUT
    a = int(input())
    A = set(map(int, input().split()))
    
    N = int(input())
    for i in range(2*N+1):
        command = list(map(str, input().split(' ')))
        S = set(map(int, input().split()))
        op = command[0]
        if op == 'intersection_update':
            A.intersection_update(S)
        elif op == 'difference_update':
            A.difference_update(S)
        elif op == 'update':
            A.update(S)
        elif op == 'symmetric_difference_update':
            A.symmetric_difference_update(S)
            
    print(sum(A))