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

  • + 0 comments

    n = int(input()) s = set(map(int, input().split())) N=int(input()) for i in range(N): res=input() if res=="pop": s.pop() elif "remove" in res: s.remove(int(res[len(res)-1])) else: s.discard(int(res[len(res)-1])) print(sum(s))