我是个汉子 发表于 2018-11-27 17:44:52

之前那个搞错了,,再来

本帖最后由 我是个汉子 于 2019-1-26 19:29 编辑

taotaotaotao 发表于 2018-11-28 21:42:49

#coding=utf8
import random
secret=random.randint (1,10)
temp=input('请输入您猜的数字:')
guess=int(temp)#没转化为整型会报错
               #TypeError: '<=' not supported between instances of 'int' and 'str'
i=1
if guess>secret:
        print('大了')
if guess<secret:
        print('小了')
while (guess!=secret) and (i<=3):
        temp=input('那就请你重新输入您猜的数字吧:')
        guess=int(temp)
        if guess>secret:
                print('大了')
        if guess<secret:
                print('小了')
        i=i+1       
if i>3:
        print('输入次数超过3次了,game over!')
if guess==secret:
      print('猜对了!!')                  
      print('游戏结束')


               


taotaotaotao 发表于 2018-11-28 21:43:20

taotaotaotao 发表于 2018-11-28 21:42
#coding=utf8
import random
secret=random.randint (1,10)


发错了,不好意思哈
页: [1]
查看完整版本: 之前那个搞错了,,再来