I have a list of objects:
lista_objetos = ['acarreta', 'afeta', 'alavancagem', 'apropriadas', 'arvore', 'avaliacao']
Each object stores information, including the information itself, eg: afeta.palavra
is equal "afeta"
.
My goal is to enumerate these objects as follows:
1 - acarreta
2 - afeta
3 - alavancagem
4 - apropriadas
5 - arvore
6 - avaliacao
I'm trying to put this information in a dictionary structure, this way below, but it's not working, what I'm doing wrong ....
dic = {}
for objeto in lista_objeto:
cont = 1
dic[cont] = objeto.palavra
cont += 1
it adds an item to the dic and to .. is this wrong way to add elements in dic?