The Big If


File "python", line 6
elif "Fett" > "Boba":
SyntaxError: invalid syntax

Replace this line with your code. 
ke sure that the_flying_circus() returns True
def the_flying_circus():
    if "Boba" >= "Fett" and "Backpack" == "Jets":    # Start coding here!
        return True   # Don't forget to indent
    print "I bounty hunt for Jaba Hutt"   # the code inside this block!
    elif "Han" > "Boba":
        return False    # Keep going here.
    print "Sarlacc Pit"    # You'll want to add the else statement, too!
    print "Slave 1"


You are working with an Interpreter .....
therefor you have 2 phases if you want to execute the code
-1 the Parse phase ( here the code is read by the Interpreter and syntax-errors will be messaged )
-2 the Execution phase where your code is actually executed.

In Python code-blocks are expressed by using indentation
for instance the IF ELIF statement will have 2 code-blocks

if condition:
    # 4 space indentation which starts the IF =code-block= 
# the IF =codeblock= has ended because indentation is left !!!!
# now other code OR an ELIF are allowed
elif condition:
    # 4 space indentation which starts the ELIF =code-block= 
# here the ELIF =code-block= has been ended

As you are using the print statement, after your return statement without an indentation
the IF code-block is ended.....
After your print statement the Interpreter does not expect an ELIF
as the ELIF can only be directly after an IF.

Then there remains the problem of using a print statement AFTER a return statement.
If the Interpreter encounters the return statement
it will execute the return statement and will directly leave the function !!!!!
thus the eventuall following print statement will never be executed !!!


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