我在cmd "Indentation error expected an indented block expected"中运行我的python时收到此消息


import random
import time
name=input("Welcome to the game what is your name")
print(("This is a numbers game"),(name),
("You will be playing against the computer"))
print
("The idea of the game is to get closer than the computer to 21 without 
going over 21")
,ready="N"
ready = input("Are you ready to play the game?").lower
if ready == "yes" or ready =="y":
score=0

错误出现了,说它在这上面的行while(score)<21 and(ready=="Y" or ready==" Yes")or ready =="YES" or ready ==

"yes" or ready =="y"):
player1=random.randint(1,21)
score=(score+player1)
time.sleep(3)
print(("You have scored"),(score))
if score<21:
ready=input("Do you want to add more to your score")
if score>21:
print("Sorry Over 21 You Went Bust The Computer Wins")
else:
print("Ok well done lets see what the computer gets")

(请忽略这一行)computerscore = 0而(computerscore)<21和(computerscore)<(score):电脑= random.randint (21)computerscore = (computerscore +计算机)

time.sleep(3)
print(("The Computer Has Scored"),(computerscore))
if(computerscore)<=21 and (computerscore)>(score):
print("sorry the computer wins")
else:
print("You win well done")
break

我在CMD

下运行

你必须缩进你的条件行之后的块,这是python如何理解你是否仍然处于条件。

if a>b:
    print b
    print "I'm still in the case a>b"
else:
    print a

使用制表符或4个空格缩进

相关内容

最新更新