【发布时间】:2013-02-26 23:15:09
【问题描述】:
我正在完成一堂课,但我被卡住了。由于我是 Python 新手,很难弄清楚我哪里出错了。
#Write your two "if" statements below!
def true_function():
if #Fill in your `if` statement here!
return #Make sure this function returns `True`
def false_function():
if #Fill in your `if` statement here!
return #Make sure this function returns `False`
这是我提出的解决方案,它给了我一个错误;
#Write your two "if" statements below!
def true_function():
if 2 + 2 == 4: #Fill in your `if` statement here!
return 'True' #Make sure this function returns `True`
def false_function():
if 2 + 2 == 5: #Fill in your `if` statement here!
return 'False' #Make sure this function returns `False`
谁能帮我理解我哪里出错了?
【问题讨论】:
-
请发布错误的完整回溯。
-
这与您遇到的问题没有直接关系,但在我看来,这节课非常愚蠢。几乎没有一个很好的理由来编写一个可以保证您事先知道的结果的函数。同样,如果您知道要返回的答案,则不需要
if语句即可到达那里! -
我是个新手,我真的说不出来。它在 Codecademy 上,我想其目的是展示该结构是如何机械地工作的。为此,我认为它成功了。两个 if 语句都必须为真,才能吐出它们各自的输出。如果不是,则会被忽略。
标签: python python-2.7 python-3.x