1
In my code I am asking the user to enter the note, n° of registration and frequency of 2 people.
But I want to do this using dictionaries, so I declared the keys 'Nota'
, 'Matricula'
and 'Freqüência'
and stored in the variable aluno
. But when it comes time to display the data of these two students using the method items()
i can access only the data of 1° student or the data of 2° student, never the two together.
My question is how to display the two data of student A and student B using the dictionaries.
aluno = dict()
lista = []
for i in range(2):
aluno['Nota'] = int(input(f'Digite o nota do aluno {i+1}: '))
aluno['Matricula'] = int(input(f'Digite o numero da matricula: '))
aluno['Frequencia'] = int(input('Digite a frequencia em porcentagem: '))
print('--------------------------------------------')
lista.append(aluno.copy())
for k,v in lista[1].items():
print(k,':', v,)
Hello @Giovanni, I see that a solution proposed by the community helped you, consider accepting it, accept an answer is the best way to thank those who helped you, it will also help those who have the same problem and still keep the site healthy because your question ceases to be an unresolved question. -- It’s only worth you take a look at our [Tour] =D
– Icaro Martins
Giovanni, don’t forget that you can also vote in all the answers you found useful. Votes are an important tool on the site, besides being a way to recognize the efforts of those who asked and answered (obviously it is not an obligation, but if you think the answers were useful, consider voting for them) :-)
– hkotsubo