1 # -*- coding:utf-8 -*- 2 3 #猜数字游戏 4 5 lucky_num = 6 6 count = 0 7 8 while count < 3: 9 input_num = int(raw_input("请输入一个数字:")) 10 if input_num == lucky_num: 11 print("恭喜你,答对了!") 12 break 13 elif input_num > lucky_num: 14 print("你输入的数字大了~") 15 else: 16 print("你输入的数字小了~") 17 count += 1 18 else: 19 print("哎哟,输入太多次了...")
1 # -*- coding:utf-8 -*- 2 3 #猜数字游戏 4 5 lucky_num = 6 6 7 for i in range(3): 8 input_num = int(raw_input("请输入一个数字:")) 9 if input_num == lucky_num: 10 print("恭喜你,答对了!") 11 break 12 elif input_num > lucky_num: 13 print("你输入的数字大了~") 14 else: 15 print("你输入的数字小了~") 16 else: 17 print("哎哟,输入太多次了...")
时间: 2024-10-05 10:42:16