Created
July 6, 2022 16:33
-
-
Save sharuzzaman/785e5fa6352279cafbe9190200aabcbf to your computer and use it in GitHub Desktop.
friday the 13th
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import datetime | |
| from datetime import timedelta | |
| from datetime import date | |
| def friday_the_13th(): | |
| today = date.today() | |
| current_month = today.month | |
| current_year = today.year | |
| a = [] | |
| a.append(date(current_year,current_month,13)) | |
| for c in range(24): | |
| if current_month == 12: | |
| current_month = 1 | |
| current_year = current_year + 1 | |
| else: | |
| current_month = current_month + 1 | |
| a.append(date(current_year,current_month,13)) | |
| for b in a: | |
| if b < today: | |
| next | |
| else: | |
| if b.weekday() == 4: | |
| return "{}-{:02d}-{}".format(b.year,b.month,b.day) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment