Write a program to find birthdates till a given year on the same day you were born. Let the input be of the format: YYYY-MM-DD
Output: [‘1996-11-12’, ‘2002-11-12’, ‘2013-11-12’, ‘2019-11-12’, ‘2024-11-12’, ‘2030-11-12’, ‘2041-11-12’, ‘2047-11-12’]
Output: [‘1992-11-2’, ‘1998-11-2’, ‘2009-11-2’, ‘2015-11-2’, ‘2020-11-2’, ‘2026-11-2’, ‘2037-11-2’, ‘2043-11-2’, ‘2048-11-2’]
- split_date(birthdate): This function splits the date given by user into year, month and day.
- get_birthday(birthdate): This function is used to return the day of the week the user was born.
- true_birthdays(birthdate): This function is used to return a list of dates having the same week day the user was born.
To find the birthdates having the same day the user was born above three methods will help us. Firstly, The user will enter the date and
split_date() function will split the date into year, month and day. Then the function
get_birthday() will be used to find weekday for that particular date. Finally, the
true_birthdays() function will be used to find the list of all the dates having the same weekday. Inside this function, a for loop will be iterating from birth year to a specific year and will check if the birthdate in any particular year having the same weekday or not. If the weekday is same then that date will be added to the list of dates.
Below is the implementation.
[‘1996-11-12’, ‘2002-11-12’, ‘2013-11-12’, ‘2019-11-12’, ‘2024-11-12’, ‘2030-11-12’, ‘2041-11-12’, ‘2047-11-12’]
- Python program to find day of the week for a given date
- Python program to find the first day of given year
- Program to calculate Dooms Day for a year
- Find number of times every day occurs in a Year
- Python | Pandas Timestamp.day
- Python | Pandas DatetimeIndex.day
- Python | Pandas Period.day
- Python | Pandas PeriodIndex.day
- Python | Pandas Series.dt.day
- Get Day from date in Pandas - Python
- Python - Get Today's Current Day using Speech Recognition
- How to check whether the day is a weekday or not using Pandas in Python?
- Python program to find if two IP Address belongs to Same or Different Network
- Problems not solved at the end of Nth day
- PyQt5 QCalendarWidget - Setting First Day of Week
- PyQt5 QCalendarWidget - Getting First Day of Week
- Get the day from a date in Pandas
- 12 Reasons Why You Should Learn Python in 2019
- 10 Reasons Why You Should Choose Python For Big Data
- YOLO : You Only Look Once - Real Time Object Detection
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.