Files
python/exercises/practice/nucleotide-count/.meta/example.py
Job van der Wal e5425abe19 First files
2021-11-18 15:15:08 -08:00

19 lines
375 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(f'{abbreviation} is not a nucleotide.')