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后不能进行正确的判断
页:
[1]