matheus__serpa

Untitled

Jun 25th, 2020
1,416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. notas = {"Gabriel" : 3.4, "Bruna" : 9.4, "Lucas" : 8.1}
  2.  
  3. print('original: {}'.format(notas))
  4.  
  5. notas_por_nome = {}
  6. for aluno, nota in sorted(notas.items() ,  key = lambda x: x[0]):
  7.   notas_por_nome[aluno] = nota
  8. print('por nome: {}'.format(notas_por_nome))
  9.  
  10. notas_por_nota = {}
  11. for aluno, nota in sorted(notas.items() ,  key = lambda x: x[1]):
  12.   notas_por_nota[aluno] = nota
  13. print('por nota: {}'.format(notas_por_nota))
Advertisement
Add Comment
Please, Sign In to add comment