下面是一个项目,我工作的一些代码:我需要修正哪些内容才能使此代码返回“True”?
# Make sure that the_flying_circus() returns True
def the_flying_circus():
if (3 < 4) and (-10 > -20):# Start coding here!
print "Hey now!"# Don't forget to indent
# the code inside this block!
elif (-4 != -4):
print "Egad!"# Keep going here.
else:
return True # You'll want to add the else statement, too!
我不知道为什么,这不符合具有代码返回True
的条件。有什么想法吗?
由于表达式'(3 <4)和(-10> - 20)'总会是'真的'?或者我误解了你的问题? – 2014-09-29 21:08:38
如果前面的if语句都不成立,'else'将会被执行。由于第一个条件是真的,否则不会执行。如果你总是想返回true,把它放在'else'分支之外。 – 2014-09-29 21:09:08
尝试'print the_flying_circus()' – 2014-09-29 21:09:09