dictionary=hash table
python的built-in物件中...
可變的物件都沒有__hash__, 如list, dict, set等等
所以不能拿來當字典的key
回到你的問題
從Dict中取出特定數目的問題問user
import random
Dict={"紅":"紅色","成":"成功","失":"失敗","漂":"漂亮","勇":"勇敢",
"天":"天空","寫":"寫字","力":"力量","走":"走路","手":"手機"}
num = 5
TwoWords=list(Dict.keys())
random.shuffle(TwoWords)
print("\n")
correct = 0
incorrect = 0
for word in TwoWords[:num]:
print(word)
term=input ("請輸入詞彙:")
if term==Dict[word]:
print("答對了!\n")
correct+=1
else:
print("答錯了,應該是%s...\n"%Dict[word])
incorrect+=1
print('你答對%i題,答錯%i題!' %(correct, incorrect))