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")
posted @ 2017-12-08 20:57  雨之愿风  阅读(173)  评论(0编辑  收藏  举报