Skip to content

Commit

Permalink
Solutions to Python Sets section
Browse files Browse the repository at this point in the history
  • Loading branch information
sknsht committed Jun 3, 2018
1 parent af5e346 commit 57540fa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Python/Sets/Set .discard(), .remove() & .pop()/Solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
n = input()
elements = set(map(int, input().split()))

for _ in range(int(input())):
command = input().split()
operation = command[0]
args = command[1:]

if operation != 'pop':
operation += '(' + ','.join(args) + ')'
eval('elements.' + operation)
else:
elements.pop()
print(sum(elements))

0 comments on commit 57540fa

Please sign in to comment.