code: def find_day_by_weekday_offset(year, month, weekday, offset):
      
      # thanks calendar :)
      cal = calendar.monthcalendar(year, month)
  
      # If we ask for a -1 day, just reverse cal
      if offset < 0:
          offset = abs(offset)
          cal.reverse()
  
      # ok go for it
      nb_found = 0
      try:
          for i in range(0, offset + 1):
              # in cal 0 mean "there are no day here :)"
              if cal[i][weekday] != 0:
                  nb_found += 1
              if nb_found == offset:
                  return cal[i][weekday]
          return None
      except KeyError:
          return None
docs: Get the day number based on a date and offset
  
      :param year: date year
      :type year: int
      :param month: date month
      :type month: int
      :param weekday: date week day
      :type weekday: int
      :param offset: offset (-1 is last, 1 is first etc)
      :type offset: int
      :return: day number in the month
      :rtype: int
  
      >>> find_day_by_weekday_offset(2010, 7, 1, -1)
      27