Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for When is Friday? by new_hoschi
from datetime import datetime
def friday(day):
# construct a datetime object, get its weekday (as a number between 0 and 6)
# calculate the difference to friday(==4) and in case this is negative (i.e.
# Saturday or Sunday) calculate the modulus -1 -> 6 , -2 -> 5
dday=datetime.strptime(day,"%d.%m.%Y")
return (4-dday.weekday())%7
## or even shorter but barely readable in one line:
# return (4-datetime.strptime(day,"%d.%m.%Y").weekday())%7
June 10, 2020