The Big If (SyntaxError)


#1



https://www.codecademy.com/en/courses/python-beginner-BxUFN/4/1?curriculum_id=4f89dab3d788890003000096#


File "python", line 3
if answer = 1:
^
SyntaxError: invalid syntax


It looks correct. Compared it with previous code. Not sure where the syntax error occurred.


# Make sure that the_flying_circus() returns True
def the_flying_circus(answer):
    if answer = 1:
        print "True"
    elif answer < 1 and > -1:
        print "False"
    else:
        print "N/A


#2

Write an if statement in the_flying_circus(). It must include:

if, elif, and else statements;
At least one of and, or, or not;
A comparator (==, !=, <, <=, >, or >=);

Finally, the_flying_circus() must return True when evaluated.

Your code appears to fall short of these instructions.

Note on comparison and logical operators:

==  is the operator for equality comparison

=  is the operator for assignment

and

>>> x = 0
>>> x < 1 and > -1
SyntaxError: invalid syntax
>>> -1 < x < 1
True
>>> x < 1 and x > -1
True
>>>

#3

Ok, thanks for clarifying this for me.


#4

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