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()
>>> 展开
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()
>>> 展开
2015-08-13
展开全部
php 是最好的语言
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询