The Big If


#1

It says I passed the test, however, it did not print anything to the console. So a little confused.

def the_flying_circus():
if 5 * 2 == 11 - 1 or 10 == 9:
return True
print "this is true"
# the code inside this block!
elif 5 * 2 == 11 - 1 or 10 == 9:
return False
print "This is ■■■■"
else:
print "■■■■ is happening"


#2

When you return things they are not printed in the interpreter of codecademy. If you tried just print, it would've displayed whatever you want to print. After return, the function won't run anymore, it would just give the result and end. That's it, there's nothing to be confused. :smile:


#3

Even if you just have the print statements, the console will still remain as None. Here is the test.


#4

You can get your statements to print by doing this.

def the_flying_circus():
	if 5 * 2 == 11 - 1 or 10 == 9:
		print "this is true." # 2
		return True
	elif 5 * 2 == 11 - 1 or 10 == 9:
		print "This is ■■■■"
		return False # 2
	else:
		print "■■■■ is happening"
		
the_flying_circus() # 1

You need to:
1. call the function for those print statements to work (You've only defined the function. Python won't call it for you hence nothing gets printed) and
2. put them before your return statements.
It is because as @tagjumper54263 has mentioned:

After return, the function won't run anymore, it would just give the result and end.


#5

Yep that's it. It would work if you printed it before the return. Plain and simple.


#6

So just do this:

def the_flying_circus():
	if 5 * 2 == 11 - 1 or 10 == 9:
	    print "this is true"
	    return True
	elif 5 * 2 == 11 or 10 == 9:
	    print "This is False"
	    return True
	else:
		print "Nothing is happening"

#7

You are welcome for the likes.


#8

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