2015-10-05 60 views
-3

所以後,我一直在試圖運行這個程序,但每當我按Enter鍵啓動它(這部分工作正常),它不斷拋出這個錯誤:的時候老是值誤差改變我的代碼

ValueError: dictionary update sequence element #0 has length 1; 2 is required 

這是觸發這一行:

words = ["Games","Development","Keyboard","Speed","Typer","Anything","Aplha","Zealous","Accurate","Basics","Shortcut","Purpose","Window","Counter","Fortress","Modification","Computer","Science","History","Football","Basketball","Solid","Phantom","Battlefield","Avdvanced","Warfare","Download","Upload","Antidisestablishmentarianism","Supercalifragilisticexpialidocious","Discomobobulation","Liberated","Assassin","Brotherhood","Revelation","Unity","Syndicate","Victory"] 

def nextWord(): 
     global score 
     entry.focus_set() 
     if entry.get().lower() == words[1].lower(): 
      score += 1 

     entry.delete(0, tkinter.END) 
     random.shuffle(words) 
     label.config(str(words[1]), text=str(words[0])) 
     scoreLabel.config(text="Score: " + str(score)) 

我知道,它可能是在

(str(words[1]) 

部分原因是我CH在那裏篡改了一些代碼來嘗試修復另一個錯誤(我這樣做)。那麼有什麼我錯過/錯過了嗎? 謝謝。

+2

這裏沒有足夠的代碼來告訴你什麼是錯的。 –

+0

完整的代碼和追溯錯誤。 – Leb

+0

另外,你想用'label.config(str(words [1]),text = str(words [0]))''做什麼? –

回答

2
label.config(str(words[1]), text=str(words[0])) 

config只接受一個命名參數,但您給它一個命名參數和一個位置參數。嘗試:

label.config(text=str(words[0])) 
+0

感謝您的幫助,下次我將嘗試正確構建我的問題。 – Ernxst

相關問題