首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >这段if/else条件代码有什么问题?

这段if/else条件代码有什么问题?
EN

Stack Overflow用户
提问于 2013-04-18 02:52:02
回答 1查看 78关注 0票数 0
代码语言:javascript
复制
def who_are_you(tall,ginger,wears lenses):
    if tall and ginger and wears glasses:
        return "student 1"
    if tall and not ginger and not wears lenses:
        return " student 2"
    if ginger and wears lenses and not tall:
        return "student 3"
    if wears lenses and not tall and not ginger:
        return "student 4"
    if tall and wears lenses and not ginger:
        return "student 5"
    else:
        return "bossman"    

#This is just for you to see what happens when the function is called
print who_are_you(True, True, True)
EN

回答 1

Stack Overflow用户

发布于 2013-04-18 02:53:06

您发出的问题是变量名为wears lenses

它应该是wears_lenses或其他什么。不能在变量名中使用空格。

另外,变量名也有一个问题:wears glasses应该为wears_lenses

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16067844

复制
相关文章

相似问题

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