局部变量'?'在分配之前引用

时间:2017-08-11 17:38:41

标签: python

我是Python和编程的新手。我想知道如何摆脱这个编译错误

def health_risk(activity_level, is_smoker):
    """Counts the aliveness of a person"""  
    alive = "alive?" or "sedentary"
    very_low = "low" or "very low"
    active = "active" or "very active"    
    if (activity_level in alive) and is_smoker is True:
        xer = "extreme" 
    elif (activity_level in active) and is_smoker is True:
        xer = "medium"    
    elif (activity_level == alive) and (is_smoker is False):
        xer = "high"     
    elif (activity_level == very_low) and (is_smoker is False):
        xer = "medium"  
    elif activity_level == active and is_smoker is False:
        xer = "low"          
    return xer
level = health_risk('low', True)
print(level)

感谢您的帮助,这是我的第一篇文章,谢谢。

0 个答案:

没有答案
相关问题