马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
新人小心得
在加入随机数, 输入机会,提醒结果大小后,优化了错误后会显示剩余机会, 再次输入时有文字提醒.
import random
answer=random.randint(1,100)
t=10
guess=0
print("****advanced game set******\n\n\n")
print('pls choose a num in my mind!', end=" ")
while guess!=answer and t>0:
tmp=input()
guess=int(tmp)
t=t-1
print('\n***u got', t, 'times left***')
if guess==answer:
print('\nu did it!!', 'correct', sep='\n')
else:
if guess>answer:
print('smaller than u think')
else:
print('bigger than u think')
if t>0:
print('\ntry again', end=" ")
else:
print('\nchance up')
print('\n\n\ngame over')
|