python的猜字游戏程序没办法运行每次错误都

importrandomsecret=random.randint(1,100)guess=0tries=0print("AHOY!I'mtheDreadPirateRo... import random

secret = random.randint(1, 100)
guess = 0
tries = 0

print ("AHOY! I'm the Dread Pirate Roberts, and I have a secret!")
print ("It is a number from 1 to 99, I'll give you 6 tries.")

while guess != secret and tries < 6:
guess = input("What's yer guess? ")
if guess < secret:
print ("Too low,ye scurvy dog!")
elif guess > secret:
print ("Too high, landlubber!")
elif guess == secret:
print ("good")
tries = tries +1
if tries == 6:
print ('No more guesses! better luck next time, matey!')
print ('The secret number was', secret)
break
以上是程序

错误是
Traceback (most recent call last):
File "D:/New Folder/猜字游戏.py", line 12, in <module>
if guess < secret:
TypeError: unorderable types: str() < int()
>>>
展开
 我来答
albumin
2015-08-13 · TA获得超过1.2万个赞
知道大有可为答主
回答量:4889
采纳率:87%
帮助的人:2410万
展开全部
guess = input("What's yer guess? ")

改为
guess = int(input("What's yer guess? "))
追问
还不行
匿名用户
2015-08-13
展开全部
php 是最好的语言
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式