matheus__serpa icon

Untitled

matheus__serpa | PRO | 06/25/20 07:19:34 PM UTC | 0 ⭐ | 1584 👁️ | Never ⏰ | []
Python |

420 B

|

None

|

0 👍

/

0 👎

notas = {"Gabriel" : 3.4, "Bruna" : 9.4, "Lucas" : 8.1}
 
print('original: {}'.format(notas))
 
notas_por_nome = {}
for aluno, nota in sorted(notas.items() ,  key = lambda x: x[0]):
  notas_por_nome[aluno] = nota
print('por nome: {}'.format(notas_por_nome))
 
notas_por_nota = {}
for aluno, nota in sorted(notas.items() ,  key = lambda x: x[1]):
  notas_por_nota[aluno] = nota
print('por nota: {}'.format(notas_por_nota))

Comments