我使用下面的代码,但显示出一些错误 - 索引超出范围如何翻译英语瑞典使用的字典在python
english=["merry", "christmas", "and", "happy", "new", "year"]
swedish=["god","jul","och","gott","nytt","år"]
dict = {english[n]: swedish[n] for n in range(len(english))}#dictionary
trans_list=[]#list to save translated words
def trans(list):
n=0
for word1 in list:
for word2 in english:
if word1==word2:
trans_list[n]=dict[word2]
n=n+1
print trans_list
list2=[]
list =["merry", "christmas", "and", "happy", "new", "year"]
trans(list)