I am confused about the error I am getting.
My code is as below:
result = getString(argument_x)
print result # it returns "PASS"
if result ="PASS"
When I try to launch it, it shows an error for the last line:
SyntaxError: invalid syntax
I am confused about the error I am getting.
My code is as below:
result = getString(argument_x)
print result # it returns "PASS"
if result ="PASS"
When I try to launch it, it shows an error for the last line:
SyntaxError: invalid syntax
Comparison for equality is done using the ==
operator (you're using a single =
which is for assignments only). Also, you're 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"
You need a colon
at the end of the line,this way if result == "PASS":
You missed the colon operator after the if statement.
result = getString(argument_x)
print result # it returns "PASS"
if result == "PASS":
print 'something'
You missed the colon operator after the if statement.
result = getString(argument_x)
print result # it returns "PASS"
if result == "PASS":
print 'something'