python学习日志一
今日学习内容
小甲鱼python视频
小游戏最终改进版代码
import random
times = 3
secret = random.randint(1,10)
print('------------来玩个小游戏---------------')
guess = 0
print('不妨猜一下小甲鱼现在心里想的是那个数字:',end = " ")
while (guess != secret) and (times > 0):
temp = input()
#print(type(temp))
while temp.isdigit() != True:
print('输入的数字不是整数!',end='')
temp = input('请输入一个整数:')
else:
guess = int(temp)
times = times - 1
if guess == secret:
print('猜的真准啊!')
print('哼,猜中了也没有奖励!')
else:
if guess > secret:
print('大了~~')
else:
print('小了~~')
if times > 0:
print('再试一次吧')
else:
print('没有猜对,机会用光了!')
print('游戏结束,不玩啦!')