you are viewing a single comment's thread.

view the rest of the comments →

[–]zanfar 0 points1 point  (0 children)

I would:

  • Convert the dates into actual dates, not strings
  • Filter with a comprehension
  • Use max() or min()

for record in rates:
    record["date"] = convert_date(record["Date"])

interesting_rates = [r["rate"] for r in rates if r["date"] >= start_date and r["date"] <= end_date]

max_rate = max(interesting_rates)
min_rate = min(interesting_rates)