1
I have a list of objects:
lista_objetos = ['acarreta', 'afeta', 'alavancagem', 'apropriadas', 'arvore', 'avaliacao']
each object stores information, among that information the word itself, Ex: 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 into a dictionary, this way to follow, 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 dic and to.. it is wrong that way to add elements in dic?
Gee... I didn’t even realize it, this cont = 1 inside the loop that was holding me back.. Thanks @andersoncarloswoss
– William Henrique