def previous_workday(dt):
 dt -= timedelta(days=1)
 while (dt.weekday() > 4):
  dt -= timedelta(days=1)
 return dt

def previous_workday ( dt ) : dt -= timedelta ( days = 1 ) while ( dt . weekday ( ) > 4 ) : dt -= timedelta ( days = 1 ) return dt
returns previous weekday used for observances .