def previous_week_day(base_date, weekday):
 day = (base_date - timedelta(days=1))
 while (day.weekday() != weekday):
  day = (day - timedelta(days=1))
 return day

def previous_week_day ( base_date , weekday ) : day = ( base_date - timedelta ( days = 1 ) ) while ( day . weekday ( ) != weekday ) : day = ( day - timedelta ( days = 1 ) ) return day
finds previous weekday .