Python--猜年龄问题
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Huanglinsheng # my_age = 30 # user_input = int(input("input your guess num:")) # # if user_input == my_age: # print("Congratulations,you got it!") # elif user_input < my_age: # print("think bigger!") # else: # print("think smaller!") my_age = 28 count = 0 while count < 3: user_input = int(input("input your guess num:")) if user_input == my_age: print("Congratulations, you got it !") break elif user_input < my_age: print("Oops,think bigger!") else: print("think smaller!") count += 1 # 每次loop 计数器+1 else: print("猜这么多次都不对,你个笨蛋.")
posted on 2018-07-23 16:52 huanglinsheng 阅读(166) 评论(0) 编辑 收藏 举报