move practice exercise example solutions to .meta/
This commit is contained in:
committed by
BethanyG
parent
2bb2d08be0
commit
d7e8e0c736
18
exercises/practice/nucleotide-count/.meta/example.py
Normal file
18
exercises/practice/nucleotide-count/.meta/example.py
Normal file
@@ -0,0 +1,18 @@
|
||||
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))
|
||||
Reference in New Issue
Block a user