The task I was given is to create a program that will check if the current date is your birthday. If it is, print "Happy Birthday!". If not then output how many days left till your birthday.
I have been struggling with this task, I think I have got it working, but how do I remove the comma "," and the time "0:00:00" output from the result?
I only want it to display the number of days and the word days.
INPUT: 1989 6 21
DESIRED OUTPUT (at time/date of asking question!): 349 days
NOT: 349 days, 0:00:00
Hope that is clear and thanks in advance!
--
So far I have:
import datetime
today = datetime.date.today()
user_birth_year = int(input("Enter year of birth i.e. 1989: "))
user_birth_month = int(input("Enter month of birth i.e. for June enter 6: "))
user_birth_day = int(input("Enter day of birth i.e. for 21st enter 21: "))
my_birthday = datetime.date(today.year, user_birth_month, user_birth_day)
if my_birthday == today:
print("Happy Birthday!")
else:
if my_birthday < today:
my_birthday = my_birthday.replace(year=today.year + 1)
days_until_birthday = my_birthday - today
print(days_until_birthday)
else:
days_until_birthday = my_birthday - today
print(days_until_birthday)