people = 30#变量people赋值30 cars = 40#变量cars赋值40 buses = 15#变量buses赋值 if cars > people:#如果出租车比人多 print("We should take the cars")#我们坐出租车 elif cars < people:#elif后面必须跟条件, print("We should not take the cars")#我们不能坐出租车 else:#else跟冒号,直接输出打印, print("we can`t decide") if buses > cars: print("That`s too many buses") elif buses< cars: print("Maybe we could take the buses") else: print("We still can`t decide") if people>buses: print("Alright,let`s just take the buses") else: print("Fine,let`s stay home then")
:#elif后面必须跟条件,else无需跟条件,要跟一个冒号