1
下面的代碼給出了錯誤UnboundLocalError:賦值之前引用局部變量「currentpl」局部變量「currentpl」賦值之前引用:錯誤UnboundLocalError:
def play(num_sq, user_choice):
drawStrip(num_sq)
if user_choice == 0:
currentpl = 1
elif user_choice == 1:
currentpl = 2
while gameover(num_sq):
if currentpl == 1:
pick = getPlayerPick(num_sq)
while not validPlay(pick, num_sq):
pick = getPlayerPick(num_sq)
makePlay(pick, player_col[currentpl])
if currentpl == 2:
pick = computerSelection(num_sq)
makePlay(pick, player_col[currentpl])
currentpl = togglePlayer(currentpl)
if currentpl == 2:
return "User"
return "Computer"
我怎樣才能解決這個問題?謝謝你的幫助!
對不起,斯圖爾特,是有點新的這個,所以我不明白你在說什麼 – deedee 2014-11-23 02:16:23
@deedee不用擔心 - 我試圖在我的答案上面粘貼 – 2014-11-23 02:23:31
好吧我要試一試,讓你知道結果 – deedee 2014-11-23 02:34:59