저는이 기능을 작성 했으므로 제대로 작동하지 않습니다. 어떤 아이디어라도 제발? 나는DNA 시퀀스 문자열에있는 뉴클레오티드를 계산하십시오.
이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
는 여기까지 보여주는 DNA 관련 통계를 많이 참조하십시오. 이것은 상당히 일반적인 숙제 문제입니까? – tylerl
* 모든 * 뉴클레오티드를 계승 하시겠습니까, 아니면 전달 된 것입니까? – nneonneo
''char ''('A'또는 'T'또는 'C'또는 'G')'는 char가 'G'인 경우 ('또는'연산자의 작동 방식으로 인해) '와 동일합니다. – Tadeck