code: def safe_int(val, default=None):
      
  
      try:
          val = int(val)
      except (ValueError, TypeError):
          val = default
  
      return val
docs: Returns int() of val if val is not convertable to int use default
      instead
  
      :param val:
      :param default: