Why is it not necessary for something to be written in the 'if' statement of the 'Big If' review?


answer = 30 # Make sure that the_flying_circus() returns True
def the_flying_circus():

if (): Start coding here!
print True # Don't forget to indent
# the code inside this block!
elif (30 <= 10) and (20 != 30):
print False # Keep going here.

    return True # You'll want to add the else statement, too!

Why did this work? It wouldn't let me move on the next lesson unless I left the 'if' statement blank.


Are you trying to code in Python or Java?

Python Code

def ask_if():
    This function simply ask a question and returns a value based on the input.
    # For Python 3.* use input
    ask = raw_input("Enter a string or number")
    return "Number" if ask.isdigit() else "String"


Java Code

public class flying_circus {

    public static void main(String[] args) {
        System.out.println("Enter a number!");
        Scanner holdInput = new Scanner(System.in);
        int hold = holdInput.nextInt();
        System.out.print("You entered " + hold + "\n");

Or you could be using something else, no idea. If you would be so kind could you please codify your code with the </> key that is directly above your entry area for a post.


I get what you are asking now, parentheses are completely optional when it comes to python if/else expressions.


a = ()
# OUTPUT: <class 'tuple'>
if () == tuple():

As you can see easily if you do not input the correct information or use the syntax correctly you will not get the results that you want.


So I did enter something wrong and yet the program mistakenly marked () as being a part of the statement?


Hi @v8pluver ,

As @zeziba's code demonstrates, () is a tuple. In fact, it is an empty tuple.

Try this in a Python interpreter ...

if ():
    print "The if block executed."
    print "The else block executed."

Output ...

The else block executed.

The if header always must include a condition. So this will not work at all ...

    print "The if block executed."

But the empty tuple does qualify as a condition that is equivalent to False, and that explains the output that stated, The else block executed..

When you added the () to your code, it became valid, with a condition equivalent to False connected with the if block. Your code passed Codecademy's test, because your else block executed, and returned True, as the exercise instructions requested.


Ohhhh.... I get it now. Thanks!