我一直在为这组代码中的最后一个获取语法错误,我不知道为什么。它不是一个错误的间隔它的语法所以我不明白我做错了什么。我想知道是否有人可以提供帮助。代码如下。
if pcolor == winner:
print ('Correct!')
while player == correct:
phl = input('Higher or lower?').strip().lower()
randcard = computer_pick_card()
if randcard == 'A':
player = correct
print ('The card was an Ace')
print ('Correct!')
else:
if last_card != ():
if phl == higher:
if randcard >= last_card:
player = correct
print ('The card was ', randcard)
print ('Correct!')
elif randcard < last_card:
player != correct
print ('The card was ', randcard)
print ('You lose')
elif phl == lower:
if randcard >= last_card:
player != correct
print ('The card was ', randcard)
print ('You lose')
elif randcard < last_card:
player == correct
print ('The card was ', randcard)
print ('Correct!')
else:
if phl == higher:
if randcard >= card2:
player = correct
print ('The card was ', randcard)
print ('Correct!')
elif randcard < card2:
player != correct
print ('The card was ', randcard)
print ('You lose')
elif phl == lower:
if randcard > card2:
player != correct
print ('The card was ', randcard)
print ('You lose')
elif randcard <= card2:
player == correct
print ('The card was ', randcard)
print ('Correct!')
last_card = randcard
return last_card
last_card = ()
else:
print ('You lose')
答案 0 :(得分:2)
在python中间距是语法。
你没有正确的间距。
if ...
...
last_card = ()
else:
...
应该是
if ...
...
last_card = ()
else:
...