Challenge - #52 - Set .discard(), .remove(), & .pop()

n = int(input())

s = set(map(intinput().split()))
for i in range(int(input())):
    inp = input()
    if inp == "pop":
        s.pop()
    else:
        command , value = inp.split()
        if command == "discard":
            s.discard(int(value))
        else:
            s.remove(int(value))
print(sum(s))

Comments

Popular posts from this blog

Challenge - #48 - Incorrect Regex

Challenge - #43 - Time Delta