#coding=utf-8
#赋值
people = 20
cars = 19
buses =15
#赋值
people = 20
cars = 19
buses =15
if cars > people and buses < cars:
print "Take cars!!!!"
elif cars > people or buses > cars:
print "TAKE WHATEVER YOU WANT."
elif cars < people and buses < cars:
print "Better stay at home."
else:
print "Better to take the buses."
#note:
else:
XXXXXXX
else后面直接接:,然后缩进后,输出结果。
为什么不可以这样子:
if cars > people and buses = cars:
print "whatever"
原因: 布尔表达式是么有只有一个等号的。
elif只会运行它遇到的第一个True, 其他会忽略的。