为什么这个不打印true?

huangapple go评论65阅读模式
英文:

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().

huangapple
  • 本文由 发表于 2023年6月19日 09:31:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76503150.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定