You are viewing a single comment's thread. Return to all comments →
n=int(input())
s = set(map(int,input().split()))
N=int(input())
for i in range(N) :
choice=input().split() if choice[0]=="pop" : s.pop() elif choice[0]=="remove" : s.remove(int(choice[1])) elif choice[0]=="discard" : s.discard(int(choice[1]))
print (sum(s))
Seems like cookies are disabled on this browser, please enable them to open this website
Set .discard(), .remove() & .pop()
You are viewing a single comment's thread. Return to all comments →
Easy code for beginners Python3
n=int(input())
s = set(map(int,input().split()))
N=int(input())
for i in range(N) :
print (sum(s))