BasicFiles & CSV10 points

Wet days in a world city

A travel startup recommends cities by how often it rains during a trip. Its weather feed is saved in weather.csv: one row per city per day for the first 45 days of July 2025.

  • date: the day (YYYY-MM-DD)
  • city: city name
  • temp_c: average temperature in degrees Celsius
  • rain_mm: rainfall in millimetres

Task: the first input line is a city name (written exactly as in the file), the second line is a rainfall threshold in mm (a number, may have decimals). A day is wet when rain_mm is greater than or equal to the threshold. Print exactly two lines: Wet days: N and Rain on wet days: X mm where X is the total rain of the wet days with 1 decimal (f"{x:.1f}"). For a city that is not in the file, N is 0 and X is 0.0.

Files your program can read

weather.csv271 lines
date,city,temp_c,rain_mm
2025-07-01,Lisbon,21.4,0.0
2025-07-01,Nairobi,22.6,0.0
2025-07-01,Mumbai,29.1,0.0
2025-07-01,Toronto,21.0,0.0
2025-07-01,Sydney,14.8,0.0
2025-07-01,Reykjavik,7.9,0.0
2025-07-02,Lisbon,21.1,0.0
...

Open them by name, for example open("weather.csv").

Sample test

Input

Lisbon
5

Expected output

Wet days: 12
Rain on wet days: 143.3 mm

Your answer is also checked against 4 hidden tests.

Need a hint?

Convert rain_mm with float() before comparing, and add to a running total only inside the if.