python缩进错误,求教。
elif这里总是提示pythonexpectedanindentedblock,可是不会改啊,求教怎么办,刚学python3。谢谢了...
elif这里总是提示python expected an indented block,可是不会改啊,求教怎么办,刚学python3。谢谢了
展开
1个回答
展开全部
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=int(input("What's you guess?"))
if guess<secret:
print("Too low,ye scurvy dog!")
elif guess>secret:
print("Too high,landlubber!")
tries=tries+1
if guess==secret:
print("Avast !You got it ! Found my secret,you did!")
else:
print("No more guesses!Better luck next time,matey!")
print("The secret number was",secret)
python是依靠缩进判断语句块的,因此while,if的子语句要多缩进一个单位
学的什么书,告诉一下,省得下次答的时候还是自己敲代码
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询