vendredi 6 août 2021

If statement with the datetime library in python

This is the code i have so far. I want to check if it is a certain date and then print a fitting answer(for special days eg. Birthdays, etc). Only problem is that even tho it tells me todays date is 06/08/2021, when i check for it in the if statement it says its not that date. Why is that

from datetime import date

tday = date.today()
print(str(tday))

if str(tday) == "06/08/2021":
    print("Today's date:", tday)
else:
    print("Today's date isn't:", tday)

Aucun commentaire:

Enregistrer un commentaire