import datetime def get_last_friday(date_string): parts = date_string.split("/") mounth = int(части[0]) year = int(части[1]) if mounth == 12: first = datetime.data(year +1,1,1) else: first = datetime.date(year,mounth+1,1) last = first - datetime.timedelta(days=1) now = last while True: if now.isoweekday() ==5: break else: now = now - datetime.timedelta(days=1) result = now.strftime("%d.%m.%Y") return result