You are viewing a single comment's thread. Return to all comments →
set.pop is meh, so convert to list and pop consistently
n = input() s = set(map(int, input().split())) for i in range(int(input())): c = input().split() if c[0] == 'pop': s_list = list(s) s_list.pop(0) s = set(s_list) elif c[0] == 'remove': s.remove(int(c[1])) else: s.discard(int(c[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 →
set.pop is meh, so convert to list and pop consistently