From ce0c71df823cc5d3ebe4f4b6b55a8109bb9a5fc9 Mon Sep 17 00:00:00 2001 From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> Date: Mon, 20 May 2024 09:20:34 +0000 Subject: Mon, May 20, 2024, 2:20 AM -07:00 --- wk7/lect/favorites.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'wk7') diff --git a/wk7/lect/favorites.py b/wk7/lect/favorites.py index fcdc97c..68fa769 100644 --- a/wk7/lect/favorites.py +++ b/wk7/lect/favorites.py @@ -15,6 +15,5 @@ with open("favorites.csv") as file: favorite = row["language"] counts[favorite] += 1 -for favorite in sorted(counts, key=counts.get, reverse=True): - print(favorite, ':', counts[favorite]) - +for favorite, count in counts.most_common(): + print(f"{favorite}: {count}") -- cgit v1.2.3