0
我不斷收到這組代碼中最後一個語法錯誤,我不知道爲什麼。它不是一個錯誤的間距其正義的語法,所以我不明白我做錯了什麼。我想知道是否有人可以幫忙。代碼如下。在我的if else語句中出現語法錯誤
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')
什麼是錯誤,到底是什麼? – sachleen
。你完全混合變量的定義與if語句...你應該閱讀python的基礎知識「player = correct」是一個定義,但不是播放器==定義... – user1767754