python练习-if-else-or

color=raw_input("enter your favorite color:")   
if color =="red" or color =="green" or color =="black":    
    print "you can play this game."    
else:     
    print "sorry ,you can't play the game."

#开始不明白为何==后的color必定要带“”,而以前的age==不用“”。运行了一次,报错xxx不是一个变量。若是不带“”会被认为是一个变量,而数字是不能够做为变量名,因此不会被当作变量处理而报错
#还有我将代码改为这样if color =="red" or color =="green" and color ==3  ,代码能跑,可是我输入3后不能进行正确的判断
python

相关文章
相关标签/搜索