old_contents: NUCLEOTIDES = 'ATCGU'
  
  
  def count(strand, abbreviation):
      _validate(abbreviation)
      return strand.count(abbreviation)
  
  
  def nucleotide_counts(strand):
      return {
          abbr: strand.count(abbr)
          for abbr in 'ATGC'
      }
  
  
  def _validate(abbreviation):
      if abbreviation not in NUCLEOTIDES:
          raise ValueError('%s is not a nucleotide.' % abbreviation)
  
new_contents: NUCLEOTIDES = 'ATCG'
  
  
  def count(strand, abbreviation):
      _validate(abbreviation)
      return strand.count(abbreviation)
  
  
  def nucleotide_counts(strand):
      return {
          abbr: strand.count(abbr)
          for abbr in NUCLEOTIDES
      }
  
  
  def _validate(abbreviation):
      if abbreviation not in NUCLEOTIDES:
          raise ValueError('%s is not a nucleotide.' % abbreviation)
  
subject: refactor by removing duplication.