我正在通过一堂课,我卡住了。由于我是Python新手,很难弄清楚我要出错的地方。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`
有人能帮助我了解我哪里出错了吗?
请发布错误的_full traceback_。 – 2013-02-27 00:00:30
这与您遇到的问题并不直接相关,但在我看来,这一课很愚蠢。几乎从来没有一个很好的理由来编写一个函数,它会提前知道一个保证的结果。同样,如果您知道您想要返回的答案,则不需要“if”语句即可到达该答案! – Blckknght 2013-02-27 00:11:36
因为我是新手,所以我无法确定。这是关于Codecademy的,我猜想的目的是展示结构如何机械地工作。为此,我认为它成功了。如果陈述必须是真实的,以便各自的产出被吐出。如果他们不是,他们会被忽略。 – Kimomaru 2013-02-27 05:24:37