" 猜数字游戏"
2 import random
3 num = random.randint(1,100)
4 "print(num)"
5 count = 1
6 while True:
7 num1 = int(input('请输入一个1~100之间的数字:'))
8 if num == num1:
9 print('恭喜第%d次就猜中了'%count)
10 break
11 else:
12 if num > num1:
13 print('猜小了,请猜大点')
14 if num < num1:
15 print('猜大了,请猜小点')
16 int(input('猜错了,请重新输入:'))
17 count += 1
18 if count >= 4:
19 print('对不起,机会用完了,下次请加油')
20 break
~