Share your repls and programming experiences

← Back to all posts
cannot understand the syntax error.
WorldlyCuriosit (1)

Cannot understand the syntax error, at first it was compiling all correctly then suddenly it is giving a response of SyntaxError: invalid syntax at line 17.

Comments
hotnewtop
ANDREWVOSS (187)

It's because you indented elif. It should be:

if operator == "+": 
    total=num1 + num2
elif operator == "-":
    total=num1 - num2
elif operator == "*":
    total=num1 * num2
elif operator == "/": 
    total=num1 / num2
elif operator == "%":
    total=num1 % num2
elif operator == "**": 
    total=num1 ** num2
elif operator == "//":
    total=num1 // num2
else:
WorldlyCuriosit (1)

@ANDREWVOSS Thankyou, now it surely work

ANDREWVOSS (187)

@WorldlyCuriosit No problem, glad I could help!