Interpreter is choking on 'elif' statement


#1

I have the line elif x == 1: in the code that I'm writing (as the second portion of an 'if loop'), but the interpreter is stating that that line is invalid.

https://www.codecademy.com/courses/python-intermediate-en-rCQKw/0/5?curriculum_id=4f89dab3d788890003000096#

File "python", line 9
elif x==1:
^
SyntaxError: invalid syntax

I have tried using this line both with & without a space on each side of the equals operator '==' but that's made no difference. I have also checked a number of other online resources, but from all I have been able to determine, this syntax should be acceptable/correct.

(As far as indentation goes, it's indented identically with the other sections of the if loop, so I'm confident that's correct - along with the fact that -so far- the interpreter has always clearly indicated when indentation errors have been present.)

Is the elif statement/syntax somehow incorrect?


elif x == 1:


#2

the problem could also be in the line above (non matching parentheses for example), please post your full code


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.