首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我的函数( is_crowd )没有打印,我在0xf6e128e4>得到<function is_crowd at 0xf6e128e4>?

为什么我的函数( is_crowd )没有打印,我在0xf6e128e4>得到<function is_crowd at 0xf6e128e4>?
EN

Stack Overflow用户
提问于 2021-08-02 02:03:27
回答 1查看 49关注 0票数 1

标题所说的,我的函数不工作了,我该如何修复它?提前谢谢。

代码:

代码语言:javascript
复制
def is_crowd(people):
  # Write your function here.
  if people >= 30:
    return 'a crowd'
  elif people == 3:
    return 'a crowd'
  else:
    return 'no crowd'
  
# Write the rest of your program here.
crowd = int(input('Number of people: '))
print(f"There's {is_crowd} here!")

它输出的内容:

代码语言:javascript
复制
Number of people: 48
There's <function is_crowd at 0xf6e128e4> here!
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-08-02 02:08:25

需要使用()来打印函数的返回值。或者,简单地输入is_crowd将打印它的内存位置:<function .... at 0x....>

代码语言:javascript
复制
print(f"There's {is_crowd(value)} here!")
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68615690

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档