Raven has kept a weather notebook for years: one line a day, with the sky and the temperature. Rocket thinks the notebook should have a program to go with it.
"Every morning, type the weather once," he says. "The program adds it to a file and tells you the warmest day so far."
Raven nods slowly. "What do you notice about my notebook?" she asks. "Every line has the same shape. That is what makes it easy for a program to read."
Nova draws one line split into labeled parts. "Interesting," she says. "Decide the shape of a line before you write the first one. Then every line agrees."
Rocket and Raven agree on a shape: sky, a comma, then the temperature.
# weather.py
sky = input("Sky today: ").strip()
temp = int(input("Temperature: "))
with open("weather.txt", "a") as f:
f.write(f"{sky},{temp}\n")
warmest = None
with open("weather.txt") as f:
for line in f:
parts = line.strip().split(",")
t = int(parts[1])
if warmest is None or t > warmest:
warmest = t
print("Warmest so far:", warmest) The split(",") method cuts a string at every comma and gives a list of the pieces. So "sunny,24".split(",") gives ["sunny", "24"].
warmest starts as None, which means no value yet. The test warmest is None is True only until the first temperature is stored.
With two earlier days already in the file, a run looks like this:
Sky today: rainy Temperature: 17 Warmest so far: 24
Excellent work. Next week you will save whole lists and dictionaries in one go with JSON.