code: def sanitize_codon_list(codon_list, forbidden_seqs=()):
      for codon in codon_list:
          if len(codon) != 3:
              raise ValueError("Codons must have exactly 3 bases: '{}'".format(codon))
      bad_seqs = set()
      bad_seqs.union(
              restriction_sites.get(seq, seq)
              for seq in forbidden_seqs)
      bad_seqs.union(
              dna.reverse_complement(seq)
              for seq in bad_seqs)
      bad_seqs.union(
              base * (gen9.homopolymer_max_lengths[base] + 1)
              for base in dna.dna_bases)
      bad_seqs = [
              dna.dna_to_re(bs)
              for bs in bad_seqs]
      num_corrections = 0
      for bad_seq in bad_seqs:
          while remove_bad_sequence(codon_list, bad_seq, bad_seqs):
              num_corrections += 1
      return num_corrections