if x= =A:
do something for A
elif x = = B:
do something for B
else:
do something for else
python没有分支结构case, 用多个elif来实现分支。
例子:
AGE = 56
guess_age = int( input("oldboy's age:"))
print(type(guess_age))
if guess_age == AGE:
print("Contratulations..")
elif guess_age < AGE:
print("try bigger...")
else:
print("try smaller...")