Reputation: 15
I have the following code
n = int(input())
s = set(map(int, input().split()))
N= int(input())
for i in range(1,N+1):
ops=input()
li=ops.split(' ')
if li[0]=='pop':
s.pop()
elif li[0]=='discard':
s.discard(int(li[1])
elif li[0]=='remove':
if (li[1]) in s:
s.remove((li[1])
print(sum(s))
here I tried comparing the string I have in the li[0] with 'remove' but it throws an syntax error:
$python3 main.py
File "main.py", line 14
elif li[0]=='remove':
^
SyntaxError: invalid syntax
I am unable to find out where am I going wrong. Can you figure it out?
Upvotes: 1
Views: 75
Reputation: 17658
It's in the line above, and below, print misses the closing )
print(1)
And
print(2)
Also your new code misses a )
, twice
s.discard(int(li[1]))
And, here's actually a (
too many
s.remove(li[1])
Upvotes: 2