英文:
Why does this not print true
问题
只有代码部分的翻译:
a = [1, 5, 3], [4, 5, 6]
def atest():
atwo = a[0][1]
return atwo
def btest():
btwo = a[1][1]
return btwo
if btest == atest():
print("true")
print(atest())
print(btest())
输出:
5
5
希望这能帮助你解决问题。如果还有其他疑问,请随时提出。
英文:
Call me dumber than a barrel of hay in a barn in the outback thats been roasting for 20 eons but I can't see why this is not working. I am new to python and trying to practice what I learned in class today.
When I run this it does not print true which is what I need it to do and instead just prints 5 twice. I am confused as to why this is not printing true
Code
a = [1,5,3], [4,5,6]
def atest():
atwo = a[0][1]
return atwo
def btest():
btwo = a[1][1]
return btwo
if btest == atest():
print("true")
print(atest())
print(btest())
Output
5
5
Any help would be much appreciated.
答案1
得分: 2
我相信你在将它与 atest()
进行比较时漏掉了末尾的 ()
。
英文:
I believe you are missing the ()
at the end of btest
when you compare it to atest()
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论