You are viewing a single comment's thread. Return to all comments →
class Date: def __init__(self, in_string: str): day, month, year = in_string.split(" ") self.d = int(day) self.m = int(month) self.y = int(year) def __sub__(self, date): return self.d - date.d, self.m - date.m, self.y - date.y def calculate_fine(r_date, d_date) -> int: d, m, y = r_date - d_date if y > 0: return 10000 elif y < 0: return 0 if m > 0: return 500 * m elif m < 0: return 0 if d > 0: return d * 15 else: return 0 r = Date(input()) d = Date(input()) print(calculate_fine(r, d))
Seems like cookies are disabled on this browser, please enable them to open this website
Day 26: Nested Logic
You are viewing a single comment's thread. Return to all comments →