我已经编写了这个函数,但它并没有像我想要的那样运行。请问有什么想法吗?我知道问题出在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