New Year Countdown in Python | Assignment Expert

Problem Statement:

In the New Year Countdown in Python, we are given today’s date. We need to find the number of days left in the New Year date.

Code for New Year Countdown in Python:

# importing datetime module
from datetime import date, datetime
# today's date
d0 = datetime.today().strftime('%Y-%m-%d')
d0 = d0.split("-")
d0 = date(int(d0[0]), int(d0[1]), int(d0[2]))
# new year's date
d1 = date(2023, 1, 1)
# difference left in new year
difference = d1 - d0
# printing number of days left in new year
print(difference.days)

Output:

New Year Countdown in Python

Also Read:

Share:
Avatar of Harry

Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at admin@copyassignment.com Thank you