Kim*_*aru 0 python python-2.7 python-3.x
我正在上一节课而且我被困住了.由于我是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`
Run Code Online (Sandbox Code Playgroud)
这是我提出的解决方案,它给了我一个错误;
#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`
Run Code Online (Sandbox Code Playgroud)
有人能帮我理解我哪里错了吗?
True并且False是对象(或变量,常量,软关键字,或任何您想要调用的对象).它们不是字符串.
return True
Run Code Online (Sandbox Code Playgroud)
您的第二个函数也使用了错误条件,因此if块的内容将永远不会运行.它会从结束时掉下来然后返回None.
| 归档时间: |
|
| 查看次数: |
131 次 |
| 最近记录: |