I have a list of lists, in which the internal lists contain words and each internal list represents the words of each different file.
lista = [['carro','barco'],['moto','aviao'],['bike','skate']]
ie the position lista[0]
represents the word set of the file a.txt
I still have a dictionary structure that contains words, the dictionary key is serving to enumerate each word. This way:
dic = {0:'bike',1:'carro',2:'caminhao',3:'navio',4:'jato',5:'moto'}
My intention is to save in another listaNova = [[]]
, and each set of words of lista[i]
has a word that is equal to some Value of the dictionary key I keep the dictionary key in this new list, keeping the idea of that each position of listaNova[i]
is representing a file.
To my problem is how to make this loop to compare the values .. already tried several ways but none worked .... I'm doing something like:
for i in range(len(lista)):
for item in lista[i]:
for key, value in dic.items():
if value == item:
listaNova[i].append(key)
Would it be more or less the way?