Set .discard(), .remove() & .pop()

  • + 0 comments

    Here's my code:

    n, s = int(input()), set(map(int, input().split()))
    for i in range(int(input())):
        f, _, v = input().partition(' ')
        if not hasattr(set, f):
            continue
        getattr(s, f)(int(v)) if v else getattr(s, f)()
    print(sum(s))