Files
python/exercises/practice/nucleotide-count/.meta/example.py
2021-02-01 19:08:02 -08:00

19 lines
383 B
Python

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('{} is not a nucleotide.'.format(abbreviation))