If (i+3) < len(dna)


I am wondering if this part is correct.

if (i+3) < len(dna):

Shouldn’t it be?

if (i+3) <= len(dna):

If the DNA string is of length 12, as in “1234567890ab”, then


would create [0,3,6,9]

When it checks if (i+3) < len(dna), when i=9, i+3=12 and thus would NOT meet the condition of the if statement (12 < 12 evaluates to False). But, the dna[9] corresponds to the ‘0’ in the DNA string and still needs to be included. Therefore, the append statement doesn’t execute and the last three characters ["0ab"] in the string don’t get appended to the list (the resulting list being ["123","456","789"] instead of ["123","456","789","0ab"]

Am I missing something here?


I think I’ve confirmed that you need the extra =. If you modify the suspect1.txt file and change the last codon to one that is in the sample, it will not catch this match.


Please remember to include a link to the exercise so we can test it. Thanks.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.