1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| import random a = 1 while a <= 5: h = int(input('请输入1~9的数字:')) r = random.randint(1, 9) if r == h: print('系统产生的数是', r) print('猜对啦,\^o^/宝宝真棒!') break else: print('系统产生的数是', r) print('猜错啦') a = a + 1 if a > 5: print('o(* ̄▽ ̄*)o小笨蛋,没机会了呀') break
|