Files
python/exercises/practice/nucleotide-count/.meta/example.py

19 lines
383 B
Python
Raw Normal View History

NUCLEOTIDES = 'ATCG'
2013-07-31 08:38:22 -05:00
def count(strand, abbreviation):
_validate(abbreviation)
return strand.count(abbreviation)
2013-07-31 08:38:22 -05:00
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))