The Big If - What's wrong with my code?


#1

Write an if statement in the_flying_circus(). It must include:

if, elif, and else statements;
At least one of and, or, or not;
A comparator (==, !=, <, <=, >, or >=);
Finally, the_flying_circus() must return True when evaluated.
Don't forget to include a : after your if statements!

My Code:

def the_flying_circus():
if 4 < 5:
print True
elif 6 < 5:
print False
else:
print True
print the_flying_circus():


#2

Does your code comply with the instructions? You do not use any and, or, or not statements.


#3

At first do what @alan-redding told you
also remember you don't need : to call a function

print the_flying_circus(): # remove :


#4

I updated my code to the following:

if 4 < 5 and 3 == 3:
print True
elif 6 < 5 or 4 > 5:
print False
else:
print True
print the_flying_circus()

I'm getting the following error message:

Oops, try again. the_flying_circus() returned the value None, did you forget to add a return statement?

What did I do wrong?


#5

In order for it to return anything you need to have a return statement instead of your print statements.


#6

Thank you Alan-redding

I updated to the following and it worked!

ef the_flying_circus():
if 4 < 5 and 3 == 3:
return True
elif 6 < 5 or 4 > 5:
return False
else:
return True
print the_flying_circus()

Thanks for your help!


#7

No problem! I'm glad you were able to work through it. Enjoy the lessons!


#8

I did enjoy the lessons!

Now that I'm finished, it's giving me 2 options for my next course. Which do you suggest I take next?

Functions or the Pyth Language


#9

Whichever one is numerically next. Just try to do them all so you can learn as much as possible.


#10

For the Big if question it states that "Finally, the_flying_circus() must return True when evaluated." So am guessing the equation for that is True and False or not True, because If what i said is not mistaken then it comes out to be false.
Not true = False
True and False = False
False or False = False this being the final answer.

Correct me if am wrong plz, am kinda struggling on this one.


#11

You are correct, that comes out to false. If you want to test code outside of the codecademy environment and are unable to set an environment up on your own machine, you can use other online environments to test quick theories about code. Here is one that I use from time to time:
https://www.tutorialspoint.com/execute_python_online.php

Also, it is bad practice to tack on to other peoples questions. Feel free to start your own thread, there are a number of really good people on here who are more than willing to answer any questions.


#13

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