Syntax Error?


The Big If

I seem to getting the same syntax error message and I don't know how to fix it.

I expect everything to run smoothly, but that happens to be only thing wrong.
I'm not sure though, so feel free to leave other suggestions.

# Make sure that the_flying_circus() returns True
def the_flying_circus(): (5 > 6) or (6 <= 6)
if True :    print True
    print False
    print False


This exersice doesn't introduce the syntax of conditional statements pretty well, so sometimes people don't understand what they really have to do when instructions just tell them to write three conditional statements. But don't worry, they are pretty simple. (Conditional statements, not peoples)

I found this thingy from Google. Look at the code, and parallel it to your code. Conditional statements always start with if, elif or else. If you want multiple if- statements, you just have one if and all the other ones will be elifs. (Look at the example.) Else is another thing: If none of the conditionals matches, your program will display the output of the else- statement.

After this, your code needs something to check, of course. In your case, you check if the_flying_circus is True. That will work, but you can check also something else than booleans. (Look at the example again.)

If- statement ends to the output statements. Now you start doing things in other line, so add a colon to the end of the line (as you already did) and move your output statement to the next line, so the code is easy to read. Also incorrectly indented codes result syntax errors in Python.

Last thing that I have to say is, that you can't print a Boolean. Try to return it, and maybe test a few of other possible outputs? If you have still something to ask, please reply. :slight_smile:


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