from datetime import date def friday(day): day, month, year = list(map(int, day.split("."))) the_date = date(year, month, day) friday_count = 4 the_date_weekday = the_date.weekday() if the_date_weekday == 4: return 0 elif the_date_weekday < friday_count: return friday_count - the_date_weekday else: return 7 - the_date_weekday + friday_count if __name__ == '__main__': print("Example:") print(friday('23.04.2018')) # These "asserts" using only for self-checking and not necessary for auto-testing assert friday('23.04.2018') == 4 assert friday('01.01.1999') == 0 assert friday("11.11.1111") == 6 print("Coding complete? Click 'Check' to earn cool rewards!")