Mar-06-2019, 09:41 AM
Thank you very much, buran. Problem solved, according to your precious drifts. The core of solution goes around this command
easter = calc_easter(year=year)
along with the erasing of (self) attribute. Good, now. Final code, better detailed in comments, is below, and best wishes# ---------- easter_final.py ---------- from datetime import date def calc_easter(year): "Returns Easter as a date object." a = year % 19 b = year // 100 c = year % 100 d = (19 * a + b - b // 4 - ((b - (b + 8) // 25 + 1) // 3) + 15) % 30 e = (32 + 2 * (b % 4) + 2 * (c // 4) - d - (c % 4)) % 7 f = d + e - 7 * ((a + 11 * d + 22 * e) // 451) + 114 month = f // 31 day = f % 31 + 1 return date(year, month, day) # ----- Years interval --------- start_interval = 1950 end_interval = 2050 # ----- Wished month/day occurrence --------- m_target= 4 # 3 or 4 d_target= 21 # 1 to 31 # for year in range(start_interval, end_interval): easter = calc_easter(year=year) if easter.month == m_target and easter.day == d_target: print(easter.strftime('%Y-%m-%d')) # # --------- OUTPUT ------------ # C:\Training>python easter_final.py # 1957-04-21 # 2019-04-21 # 2030-04-21 # 2041-04-21 # ------------------------------