私は、私が望むように機能しないこの関数を書きました。アイデアはありますか?問題はどういうわけかcharの定義にあることを理解しています...
def count_nucleotides(dna, nucleotide):
''' (str, str) -> int
Return the number of occurrences of nucleotide in the DNA sequence dna.
>>> count_nucleotides('ATCGGC', 'G')
2
>>> count_nucleotides('ATCTA', 'G')
0
'''
num_nucleodites=0
for char in dna:
if char is ('A'or'T'or'C'or'G'):
num_nucleodites=num_nucleodites + 1
return num_nucleodites