본문 바로가기
프로그램

[파이썬] 문제 : 딕셔너리의 value를 정렬하기

by 오디세이99 2023. 12. 8.
728x90
반응형

scores = {'Korean':80, 'Math':90, 'English':80}
for item in scores.items():
    print(item)
    
print()
sorted_scores = dict(sorted(scores.items(), key=lambda item: item[1], reverse=True))
for item in sorted_scores.items():
    print(item)

728x90
반응형

댓글