In fact, what you intend to create is a list of students within a dictionary. There was a small error in your code.
You have the dictionary Dados
with the item Alunos
that keeps a list of students inside it, and each student is formed by a dictionary with the keys Nome
and Notas
.
So logic is a list of dictionaries within another dictionary:
Dados = {'Alunos': [ # o erro aconteceu neste ponto quanto você colocou { ao invés de [
{'Nome': 'Jon', 'Notas':[8,9,6]}, # primeiro aluno da lista
{'Nome': 'Giglio', 'Notas':[7,6,5]}, # segundo aluno da lista
{'Nome': 'Antony', 'Notas':[5,6,9]} # terceiro aluno da lista
]}
To scroll through students and display their data, you first need to enter the key Alunos
dictionary Dados
:
for aluno in Dados['Alunos']: # para cada aluno
print(aluno['Nome'], aluno['Notas']) # mostre o nome e nota
I need to create one more FOR inside the first FOR ??
– Nameless Man
Dictionary cannot be key to another.
– ThiagoO
As in my answer? Or otherwise?
– ThiagoO