Exercise 3 solution from datetime import date, timedelta def next_weekday(d, target): """Next date strictly after d that falls on weekday number target (Monday is 0, Sunday is 6).""" days_ahead = (target - d.weekday()) % 7 if days_ahead == 0: days_ahead = 7 return d + timedelta(days=days_ahead) d = date(2026, 11, 2) # a Monday print(next_weekday(d, 0)) # 2026-11-09 print(next_weekday(d, 4)) # 2026-11-06 print(next_weekday(d, 6)) # 2026-11-08 print(next_weekday(d, 4).strftime("%A")) # Friday (All lines were run and printed exactly the values shown.) Explanation: weekday() numbers Monday as 0 up to Sunday as 6. The modulo 7 turns "how many days forward" into a number from 0 to 6 even when the target day is earlier in the week than today. A result of 0 would mean "today", so it is replaced by 7 to get the following week, which is what "next" means here.