本帖最后由 jackz007 于 2021-10-29 11:26 编辑
如果我没有猜错的话,楼主是想随机抽取英语单词,然后从键盘输入对应中文词意,并判断是否正确吧?#coding:gbk
import random
words = ["abandon", "band", "husband", "bound",]
chinese = [["放弃", "放纵"], ["乐队", "布条", "波段"], ["丈夫"], ["被束缚的"]]
w_c = zip(words, chinese)
list_w_c = list(w_c)
new_list_w_c = []
while True:
if len(new_list_w_c) == len(list_w_c):
break
else:
word_choice = random . choice(list_w_c)
if not word_choice in new_list_w_c:
f = True
while f:
put_chinese = input('英语单词 [ %s ] 的汉语意思是 : ' % word_choice[0]) . strip()
put_chinese_es = put_chinese . split(',')
for each_put_chinese in put_chinese_es:
if each_put_chinese in word_choice[1]:
print("哎呦,不错哦,继续加油吧!!!")
new_list_w_c . append(word_choice)
f = False
if f:
print("你写的意思不正确哦,想一想或者查看资料后再填写吧!!!")
print()
|