Python Forum

Full Version: Christmas and other occasions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to make a program that can tell people the date and time (I have done this bit) but I want to add to the program, I want a way to detect the date and then display a little message depending on the date.

e.g.

#if date == 25/12
#print("Merry christmas!")
and

#if date == 1/1
#print("Happy new year!")
etc.
etc.
import datetime

today = datetime.date.today()

if (today.day, today.month) == (15, 7):
    print('today is 15th day and 7th month')
else:
    print('you have run this code on a different day')
Output:
today is 15th day and 7th month
(Jul-15-2019, 08:19 PM)Yoriz Wrote: [ -> ]
import datetime

today = datetime.date.today()

if (today.day, today.month) == (15, 7):
    print('today is 15th day and 7th month')
else:
    print('you have run this code on a different day')
Output:
today is 15th day and 7th month

Ok then thanks!
Holidays are complicated. I'd recommend just using a list someone else made, such as this one: https://github.com/dr-prodigy/python-holidays
(Jul-15-2019, 09:13 PM)nilamo Wrote: [ -> ]Holidays are complicated. I'd recommend just using a list someone else made, such as this one: https://github.com/dr-prodigy/python-holidays

I am only trying to implement set holidays, (Christmas lands on the 25th every year)