← Forum
2716 pts

## The Big If

Hi everyone!

First, my apologies for the confusion surrounding the exercise The Big If. The below should help clear things up:

1. Python doesn't like mixed spaces and tabs when you indent a line. For that reason, it's best to use four spaces (not the tab key!) when indenting. This forum answer should help you if you think indentation is the problem.
2. The exercise is looking for a properly indented if/elif/else with at least one comparison (`<=`, `>=`, `<`, `>`, `!=`, or `==`) and one boolean operator (`and`, `or`, or `not`). When indenting, make sure to indent the same amount on the line after each colon!
3. Whatever your if/elif/else evaluates to should be `True`. Here's an example of an if/elif/else that does all of the above, only I've left out the boolean operator requirement (since otherwise you could just cut/paste this answer!):

``````if 1 < 2:                # This is true...
return True          # so True will be returned!
elif 1 > 2:
return False
else:
return False
``````

For the boolean part, you can just use something like `if True and True` (which is `True`) or `if not True` (which is `False`) to meet all the requirements of the lesson.

I hope this helps, and apologies again for the confusion!

• 481 pts
43 votes

A lot of those answers here are helpful yet I might help someone but putting my solution as well.

`````` def theflyingcircus():
if 9 <= 9:
return True
print "It's true"
elif 6 == 8 or 99 < 88:
return False
else:
return False
``````

now as you know the positioning is crucial in python therefore be aware of that in every single move. if, elif and else is moved only by SPACEBAR (no Enter, no Tab). with the return and print I used Enter right after colon ":"
double-check the spaces. it took me a lot of time to do this exercies, but for your own sake, do not copy&paste it.

Show all comments
• Anonymous about 2 years ago
dosent work
• aputsey about 2 years ago
lol refreshing worked!
• Steven Musante about 2 years ago
Thank you I was totally lost
• 37 pts
28 votes

i learned more from researching why this didn't work than had it worked.

• Christopher over 2 years ago
Same Here. Poor examples and explination!
• 2716 pts
13 votes

@Davide:

Rather than cutting/pasting, try typing the code out with exactly the same formatting as shown. Cutting/pasting may change the indentation of the lines, which will cause Python to raise an error.

Show all comments
• pbs257 over 2 years ago
This assignment doesn't accept any valid solution for me. Quite frustrating. I am unable to continue...
• yateendraji over 2 years ago
Eric: So glad you explained this. I was really scratching my head when my script worked in "real" python and not in the exercise. You explained why...
• chych84 over 2 years ago
(: haha,I misunderstanding that the four spaces are in front of the "if" at first, so~ :( But now, it's ok! I'm so happy! Thank you!
• 228 pts
8 votes

FWIW, my problem was with `return` keyword. I only saw it in the early examples and it was never explained the way that the `print` command was.

My first (failed) code here was:

``````def the_flying_circus():
if 226 == 226:
print "226 is teh ossum."
elif True and False:
print "is not true"
else:
print "and nope"
``````

After eventually looking at the correct answers here and just trial and erroring, I finally added the return commands and made it work:

``````def the_flying_circus():
if 226 == 226:
return True
print "226 is teh ossum."
elif True and False:
return False
print "is not true"
else:
return False
print "and nope"
``````

What's odd about this lesson is that until now we've had Python do the work for us with regard to math and logic; suddenly here we're 'returning' the answer to...I don't know who the answer returns to.

Good luck repairing this exercise! Love the course anyway.

Show all comments
• hoop4848 over 1 year ago
GOD BLESS YOU! I've tried everyone elses code and it wont work, but yours did!
• Anonymouse over 1 year ago
Yes!! Thank you!!
• 曉瑩劉 over 1 year ago
Thank you very much!!!It is really helpful!!!
• 662 pts
5 votes

a = "lets do it"
def theflyingcircus():

`````` if a == "lets do it":
return True
elif True and False:
return False
else:
return False
``````
Show all comments
• SaN over 2 years ago
Thanks....
• Milen Vasilchev over 2 years ago
Thank you!!!
• Al over 2 years ago
Omg! Thank You This was definately a good fix
• 67 pts
5 votes

the real answer:
def theflyingcircus():
# Start coding here!
answer = "chloe"

``````if answer == "frog" or answer=="I am an idiot":

return False

elif answer == "chloe" and 1==1:

return True

else:

return False
``````
Show all comments
• Yrael about 2 years ago
IndentationError: unindent does not match any outer indentation level wat does this mean????????
• Octavian Liviu Dincan about 2 years ago
tks
• jack.sankalpgmail.com about 2 years ago
thanks man..!!stucked there but your help ..
• 861 pts
5 votes

Here we go, i can do it, in that way:

def theflyingcircus():
# Written By Renan Zapelini
a = 100
b = 100
c = 200
if a == b:
return True
elif a != b and a > c:
return False
else:
return False

Show all comments
• 165 pts
3 votes

Here is the answer:

``````def the_flying_circus():
if 3>2:
return True
elif 1>2 and 2>1:
return False
else:
return True
``````
• kp_569 over 2 years ago
Thanks. Mine was too complicated.
• 93 pts
3 votes

the real answer!!!
number = 2

def theflyingcircus():

if number < 3 and number > 1:
return True
elif number == 2:
return True
else:
print " Number is egal to 2"
return True

• 317 pts
3 votes

Wow that was frustrating. How many people discontinue the course after that?

• 1636 pts

David Marquardt

2 votes

Eric,

If we wipe the code out and type it again, can we use tabs only? Is the reason it's best to use 4 spaces idiosyncratic to this editor or just the lesson? This is an argument that apparently has no end, so low or high scope answers are equally good.

Thanks for the lessons!

• 71 pts

Niv Binyamini

2 votes

This work for me.

if 1 < 2 or 3 < 4:
return True
elif 1 > 2:
return False
else:
return False

• 272 pts
2 votes

Just wanted to share what I wrote this worked for me.

def theflyingcircus():
# Start coding here!
if circus == fun or great:
return True
print "Amazing!"
elif circus != fun:
return False
print "A waste of time."
else:
return False

• 77 pts
1 votes

Hello Eric,
Thanks a lot for the exercises. Very clever of you with the Big if solution. After some errors, I finally got it right. So kids, not just copy and paste!!!

• CJ over 2 years ago
do you know who your talking to? -_-
• 99 pts
1 votes

Thank you,I’ve solved this problem too.
But then what should I do when I want to change another line to write new codes such as return or elif.
By the way,I'm Chinese,it's really difficult for me to figure out what this course is talking about.And I think it's unnecessary to learn Python,maybe someone can translate it to Chinese.

• Brian C. Jackson over 2 years ago
they have created a learning structure for this "general purpose" programming language. it will make more sense as you complete more and more units.
• 914 pts

Falcon212

1 votes

Hopefully this will help for some of you having a problem: My Code is below.

I was getting the same line error's seen in this string, and I found out that it was a spacing error. Move your code 4 spaces on your 1st if line, as you will see in my code. Then move your return line 4 spaces on the second line. The code below is not keeping my spacing used in the exercise, so please use the 4 spaces for each and this should work for you!

I hope this helps you!!

def theflyingcircus():
# Start coding here!
if 8 < 9:
print "I get printed!"
return True
elif 8 > 9 or 7 > 8:
print "I don't get printed."
else:
print "I also don't get printed!"

• Cole Florence over 2 years ago
@Falcon212 Please use markdown to make your code be formatted as code. this will make it easier for others. Thanks.
• 87 pts
1 votes

Thanks

• 492 pts
1 votes

okay sorry for that just use this code

def theflyingcircus():
if 1 < 666:
print "Thanks PureAC"
return True
elif 893 > 932 or 32 > 32:
print "asiaskdnasl."
else:
print "asd"

``````# Start coding here!
``````

and please tab it correctly if your still having problems feel free to ask me at Tyrepickett@gmail.com

• 83 pts
1 votes

this works

def theflyingcircus():
if 1==1 and 5==2*2+1:
return True
elif 5==5:
return True
else:
return True

• tornadoelliott about 2 years ago
you need to add spaces before certain lines
• 338 pts
1 votes

else shall be always empty?

• 240 pts
1 votes

This is my code. It worked perfectly.

def theflyingcircus():

``````if number < 3 and number > 1:
return True
elif number == 2:
return True
else:
print " Number is equal to 2"
return True
``````
• 125 pts
1 votes

Thanks for this forum post. The instructions quite often are incredibly vague, you should really do something about it.

• 406 pts
1 votes
``````def the_flying_circus(pythons):
if pythons > 0 < 100:
return True
elif pythons > 100:
return not True
else:
return False
``````

After some trouble with an unexplained syntax error on line 2, (I assumed it was an identation problem), I got this code to pass on the second attempt so use the spacebar instead of relying on enter/tab, since that's what did the trick for me.

• 563 pts
1 votes

make it simple...
def theflyingcircus(answer):
if (2>1):
return "True"
elif True and False:
return "False"
else:
return "True"
print theflyingcircus(3)

• 395 pts
1 votes

def theflyingcircus(answer):
if not 9 > 1 or 1 <= 5:
return True
elif 2 < 4:
return 1
else:
return 0

• 181 pts
1 votes

Thanks this helped so much!

• 122 pts
1 votes

def theflyingcircus():
# Start coding here!
if 11> 10 or 10==10:
return True
elif 11 < 20:
return False
else:
return True

``````        #no problem like this
``````
• 44 pts
1 votes

i copied this and tried some more but it keeps saying i have an indented block and it points at if
File "python", line 3
if 1 < 2:
^
IndentationError: expected an indented block

• 90 pts
1 votes

# Make sure that theflyingcircus() returns True

a = "lets do it"
def theflyingcircus():
if a == "lets do it": # Start coding here!
return True # Don't forget to indent
# the code inside this block!
elif True and False:
return False # Keep going here.
else:
return False# You'll want to add the else statement, too!
--
Don't forget spaces

• 234 pts
1 votes

can you guys help me

def theflyingcircus():
if answer > 5 :
return
elif answer < 5 :
return
else:
return True

print greaterlessequal5(4)
print greater
lessequal5(5)
print greaterlessequal_5(6)

• 744 pts
0 votes

Eric Weinstein you are one of the best teacher

• 55 pts
0 votes

After spending at least one hour for this stupid code, I found the simplest way. It should be done as follows:
def theflyingcircus():
if 5>3:

return True
elif 5>10 or 3>5:
return False
else:
return True
Please, don't copy&&paste that might cause an error.
Cheers

• 676 pts

DaveCallaghan

0 votes

In case this helps someone else:
I found that the thing I was missing was to add "return True" or "return False" after my Boolean statements, instead of just "print True". This syntax was used but not explained in the other lessons, which is why I didn't use it on my first attempts..!

``````def the_flying_circus():
if 3>2:
return True
``````
• 62 pts
-1 votes

def theflyingcircus():
#Start coding here!
response=5
if True and False:
return False
elif response==5:
return True
else:
return False

This is my answer ,and I get to the next chapter !

• 226 pts
-2 votes

I've tried to copy and paste your code

``````if 1 < 2:                # This is true...
return True          # so True will be returned!
elif 1 > 2:
return False
else:
return False
``````

and I always get this error:

``````Traceback (most recent call last):
File "runner.py", line 105, in compilecode
File "python", line 4
elif 1 > 2:
^
SyntaxError: invalid syntax
``````

How can I fix it?
Thanks in advance.
davide

Show all comments
• Vlad over 2 years ago
def the_flying_circus(): if 3>2: return True elif 1>2 and 2>1: return False else: return True
• Vlad over 2 years ago
put your cursor at the beginning of a line that starts 'elif' or 'else' (it should be indented). hit the <backspace> key. if the cursor goes all the way to the beginning of the line, it was a <tab> character. replace it with 4 (four) spaces (i.e., hit <space bar> 4 times).
• Cole Florence over 2 years ago
@Davide Linosa Next time please post your questions in the Q&A section. this can be found in the editor at the footer of the page (with the new editor). or if you are using the old editor, it will be at the top.
• 58 pts
-2 votes

Hi,

Here is the code I'm trying but I can't seem to get it right:

def theflyingcircus():
jeff = "animator"
if len(jeff) == 2 + 3:
return True
elif len(jeff) + 2 == 100**0.5 and 2 == 5 - 3:
return True
else:
return False

Thanks in advance!

Show all comments
• Sergey Zeygerman over 2 years ago
jeff is the variable name but the actual content of it is the string "animator" which contains 8 letters. It works out.
• maysamfafa77 over 2 years ago
File "python", line 3 jeff = "animator" ^ IndentationError: expected an indented block
• maysamfafa77 over 2 years ago
whats wrong
• 185 pts

Terje Gjøse

-2 votes

My answer:

``````def the_flying_circus():

a = 100
b = 200
c = 300

of a or b == c:
return True
elif a or b <= c:
return False
else:
return False
``````

Nothing much, but thought I'd give my solution to the problem as well as others have =)

• nobody can know about 2 years ago
that doenst work !!!!!!!!!!!!!!!!!!!!
• Cole Florence about 2 years ago
It should work, try using proper indentation.
• imbriacod about 2 years ago
It doesn't work because of the "of" typo in the conditional.
• -2 votes

THE ANSWER IS FART NUGGET

• Cole Florence about 2 years ago
Spam is not appreciated here. This is for asking questions and learning.
• about 2 years ago
ITS NOT SPAM U NOOB
• Cole Florence about 2 years ago
Spam, as in using the stupid word "Noob" and improper spelling and capitalization is honestly not welcomed.
• 125 pts
-3 votes

I originally used comparisons but got nothing but errors. This is the code I used and it worked. Is this wrong?

answer = "'Tis but a scratch!"

def blackknight1():
if answer == "'Tis but a scratch!":
return True
else: "Tis not a scratch!"

return False

def blackknight2():
if answer == "Go away, or I shall taunt you a second time!":
return True
else: "Goes away"

return False

You're input is greatly appreciated. Thanks in advance!!

• Cole Florence over 2 years ago
@Lodog Next time please post your questions in the Q&A section. this can be found in the editor at the footer of the page (with the new editor). or if you are using the old editor, it will be at the top.
• 115 pts
-4 votes

Hi,
What is the best way of "saying" this...?
if 3>2:
return True

elif 1>2 and 2>1:
return False

else:
return True

WHat is the intuition behind returning "True" on the else part? I get the If and Elif part but not the 3rd part.

Thx.

• Cole Florence over 2 years ago
@cna892 Next time please post your questions in the Q&A section. this can be found in the editor at the footer of the page (with the new editor). or if you are using the old editor, it will be at the top.
• Moncef Bekhtaoui over 2 years ago
nothing is working for me

• Not started
• Not started
• Not started
• Not started
• Not started