Python if statement syntax error

Python if statement syntax error

Comparison for equality is done using the == operator (youre using a single = which is for assignments only). Also, youre missing a colon:

if result == PASS:

Many Python constructs, like if, while, and for, require a terminating colon :, and the lines following must be indented all at the same level.

The indent level is not as important as all statements associated with the conditional must be indented at the same level.

In your case, you were using an if statement:

result = getString(argument_x)
print result # it returns PASS
if result == PASS:
  print(Result equals pass)
#Add any other statements here to be executed as a result
#of result == PASS

Python if statement syntax error

You need a colon at the end of the line,this way if result == PASS:

Leave a Reply

Your email address will not be published. Required fields are marked *