Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import datetime
- from dateutil import relativedelta
- NOW = datetime.datetime.now()
- RACES = [
- {
- "name": "Ironman Texas",
- "date": datetime.datetime(2019, 4, 29)
- },
- {
- "name": "Ironman Flordia",
- "date": datetime.datetime(2020, 1, 15)
- }
- ]
- def print_message():
- for race in RACES:
- diff = relativedelta.relativedelta(race["date"], NOW)
- msg = "There are {months} months and {days} days until {race}".format(
- months=diff.months,
- days=diff.days,
- race=race["name"]
- )
- print(msg)
- if __name__ == "__main__":
- print_message()
Add Comment
Please, Sign In to add comment