What is the problem with my code?


It says syntax error on line 9, what do i do to fix this?

# Make sure that the_flying_circus() returns True
def the_flying_circus():
    if the_flying_circus() == 100:    # Start coding here!
       print "yes"    # Don't forget to indent
       return True   # the code inside this block!
    elif the_flying_circus(): True
    print "no, this can't be"    # Keep going here.
    return True # You'll want to add the else statement, too!
        print "What is this"
        return True
the_flying_circus(); 99 + 1
the_flying_circus(); 111 == 111
the_flying_circus(); 1 + 3


is a function call that is calling the same function it is in. This creates an infinite loop. We should never write code this way, unless it is intended as recursion, a concept that has not been introduced yet.

Your function takes no parameters, which is correct. It should use an if..elif.else statement, which it does, so that is correct.

It should use comparison operators and logical operators, and always return True.

Best to start over, keeping the structure but writing new conditional expressions.

def the_flying_circus():
    if ________:
        return True
    elif ________: 
        return True
        return True

Comparison operators: ==, !=, >, <, >=, <=

Logical operators: and, or, not


Could you please help me out?
I have absolutely no clue how to solve this one. I don't really understand the whole thing with the conditions or what I am expected to do.


What with this "return true" stuff? I don't see that covered in any of the previous lessons leading up to this. Why would I need to write that? What about return false? Dang it this is high school algebra all over again, people keep just pulling random new rules and things out of nowhere with no warning and act like it was super intuitive.


The exercise insists that the return value is True. All focus is on making that happen.

Given that my else statement returns True by default, the if and elif can both be imaginary expressions that yield false.

    if False > True:
        # don't need code here
    elif None and 0:
        # nor here
        return True


Then step back and return to the start of this course. Go over everything again. We cannot drill it into you. You have to do that.


I don't know what a return value is, I'll look over the previous lessons again but I've restarted this course three times and I don't remember anything about return values leading up to this exercise.


Study up on functions. They are the only objects allowed to have return statements.

We pass data to a function via its parameters. They are locally defined variables that hold the arguments that are passed in a function call, such as, my_func(args).

The way that the function passes data back to the caller is via the return statement. It is the shipper of data from function to caller where the data is now usable in that scope.

If scope is a concept you are puzzled by, then definitely stop in your tracks and go back to the beginning. We cannot hope to go forward without an understanding of scope. Paramount importance.


Well, I've already been to the beginning three times. I finally made it to this the_flying_circus() exercise and now I'm stuck since nothing I do works.


Inside your function, write an if conditional that you know to be False. Write an elif conditional that you also know to be False, then in the else, return True. Just be sure to use the required elements, a comparison and an logical operator.

False > True

is one expression that will yield False.

False and False

is another.

    return True

You don't even need code in the if and elif branches.


But wait, for this exercise, I need the_flying_circus() to return true. If both statements return false intentionally, won't that be the opposite of what I want?


Not if the else branch returns True.


Ok, I think I get it, I'll go try again and see if it works.


Eureka, it works! Thanks for your help and patience. Hopefully I can cap retries off at 3 from now on


Thanks, I'll go have another look.


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