python,制作一个判断小游戏。

今天学习了一个Python while判断小游戏,通过这个游戏,加深了Python判断语句的理解。

import random

num = random.randrange(10)
i = 0
while i < 3: 
  user = int(input('你猜是几?'))
  if user > num:
    print('大了,尝试小一点的数值。')
  elif user < num:
    print('小了!大胆一点。')
  else:
    print('厉害了,老弟!')
    break
  i += 1
else:
print('今天运气不佳,改天再尝试。')
原文地址:https://www.cnblogs.com/loganSxb/p/10942678.html