import re


def strip_appendix(lines):
  """Remove all code in the appendix."""

  p = re.compile(r"#\s*#*\s*Appendix")
  for i in range(len(lines) - 1, 0, -1):
    if p.match(lines[i], re.IGNORECASE):
      return lines[0:i]
  raise ValueError("Could not find Appendix")