大家好,我的code如下
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 21 23:47:43 2019
@author: user
"""
import random
Dict={"紅":"紅色","成":"成功","失":"失敗","漂":"漂亮","勇":"勇敢",
"天":"天空","寫":"寫字","力":"力量","走":"走路","手":"手機"}
TwoWords=list(Dict.keys())
print("\n")
correct = 0
incorrect = 0
while TwoWords:
InitialWord = random.choice(TwoWords)
TwoWords.remove(InitialWord)
print(InitialWord)
term=input ("請輸入詞彙:")
if term==Dict[TwoWords]:
print("答對了!\n")
correct+=1
else:
print("答錯了,應該是%s...\n"%Dict[TwoWords])
incorrect+=1
print('你答對%i題,答錯%i題!' %(correct, incorrect))
當出現如天,而同時出現請輸入詞彙:,這時不管我輸入甚麼字都出現錯誤訊息
如TypeError: unhashable type: 'list',所以想請教我的code應該要如何修改才行。