1

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?

1 Answer 1

2

It's in the line above, and below, print misses the closing )

print(1)

And

print(2)


update

Also your new code misses a ), twice

s.discard(int(li[1]))

And, here's actually a ( too many

s.remove(li[1])
Sign up to request clarification or add additional context in comments.

2 Comments

Same with print(2)
Yeah.. I get that.. My Bad :|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.