if elif else
- if else
格式
if xxx:
print()
else:
print()
age_of_oldboy = 56 guess_age = int(input("age:"))#age是整数,所以 需要将字符转换为整型 if guess_age == age_of_oldboy: print("you are right") else: print("think bigger")
- if elif else
格式:
if xxx:
print()
elif xxx:
print()
else:
print()
age_of_oldboy = 56 guess_age = int(input("age:"))#age是整数,所以 需要将字符转换为整型 if guess_age == age_of_oldboy: print("you are right") elif guess_age > age_of_oldboy: print("think small") else: print("think bigger")