def to_int(s):
  """Converts safely to int. On invalid output, returns 0.

  Args:
    s: String to convert
  """
  i = 0
  try:
    i=int(s)
  except ValueError:
    i = 0
  except TypeError:
    i = 0
  return i