|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import random
secret = random.randint(1,10)
times = 3
print("================================================================")
print("猜猜我现在心里想的数字是什么哦:",end = "")
while not input().isdigit():
print("大哥,格式错误,请输入正确的数字:", end = "")
else:
guess = 0
while (times>0) and (guess!= secret):
temp = input()
guess = int(temp)
times = times - 1
if guess == secret:
print("哇!你是我肚子里的蛔虫么^-^")
else:
if guess < secret:
print("小了!小了!")
else:
print("哥,大了,大了!")
if times >0:
print("再猜一次哦:", end = "")
else:
print("机会用完了T_T")
else:
print("游戏结束!")
- import random
- secret = random.randint(1,10)
- times = 3
- print("================================================================")
- guess = 0
- while (times>0) and (guess!= secret):
-
- print("猜猜我现在心里想的数字是什么哦:",end = "")
- temp = input()
- while not temp.isdigit(): #输入部分要放到主循环里面
- print("大哥,格式错误,请输入正确的数字:", end = "")
- temp = input()
- guess = int(temp)
-
- times = times - 1
- if guess == secret:
- print("哇!你是我肚子里的蛔虫么^-^")
- else:
- if guess < secret:
- print("小了!小了!")
- else:
- print("哥,大了,大了!")
- if times >0:
- print("再猜一次哦:", end = "")
- else:
- print("机会用完了T_T")
- else:
- print("游戏结束!")
复制代码
|
|