From b5d35b8fbd1bb45f428e80de305225781004866c Mon Sep 17 00:00:00 2001 From: realpython-bot Date: Fri, 28 Aug 2026 13:25:00 +0000 Subject: [PATCH] Fix broken import in football_final.py and misnamed weather function full_code/football_final.py did `import csv_reader`, but this folder only ever shipped csv_parser.py. Anyone running the final football solution hit: File "full_code/football_final.py", line 14, in import csv_reader ModuleNotFoundError: No module named 'csv_reader' The tutorial's own final listing imports csv_parser, so the module name here was simply wrong. Also renames get_name_and_avg -> get_day_and_avg in weather_final.py. That function returns `day_number`, never a name, and weather_v2.py two steps earlier already calls it get_day_and_avg -- the final file silently renamed it. Its sibling get_name_and_diff in football_final.py is left alone, because that one does return a team name. Verified: both modules import cleanly and the folder's pytest suite passes 16/16 under Python 3.14 with pytest 9.1.1 and pandas 3.0.5. Co-Authored-By: Claude Opus 5 (1M context) --- .../full_code/football_final.py | 4 ++-- .../full_code/weather_final.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python-interview-problems-parsing-csv/full_code/football_final.py b/python-interview-problems-parsing-csv/full_code/football_final.py index 1517d7c5b2..38d0829ed8 100644 --- a/python-interview-problems-parsing-csv/full_code/football_final.py +++ b/python-interview-problems-parsing-csv/full_code/football_final.py @@ -11,7 +11,7 @@ Write unit tests with Pytest to test your program. """ -import csv_reader +import csv_parser def get_name_and_diff(team_stats): @@ -22,6 +22,6 @@ def get_name_and_diff(team_stats): def get_min_score_difference(filename): with open(filename, "r", newline="") as csv_data: return min( - csv_reader.get_next_result(csv_data, get_name_and_diff), + csv_parser.get_next_result(csv_data, get_name_and_diff), key=lambda item: item[1], ) diff --git a/python-interview-problems-parsing-csv/full_code/weather_final.py b/python-interview-problems-parsing-csv/full_code/weather_final.py index 454f66b90d..50ee6cea28 100644 --- a/python-interview-problems-parsing-csv/full_code/weather_final.py +++ b/python-interview-problems-parsing-csv/full_code/weather_final.py @@ -22,7 +22,7 @@ import csv_parser -def get_name_and_avg(day_stats): +def get_day_and_avg(day_stats): day_number = int(day_stats["Day"]) avg = (int(day_stats["MxT"]) + int(day_stats["MnT"])) / 2 return day_number, avg @@ -31,6 +31,6 @@ def get_name_and_avg(day_stats): def get_max_avg(filename): with open(filename, "r", newline="") as csv_file: return max( - csv_parser.get_next_result(csv_file, get_name_and_avg), + csv_parser.get_next_result(csv_file, get_day_and_avg), key=lambda item: item[1], )