0
counter=0

i=0

dna_string = "CGATATATCCATAG" 

if dna_string[i:i+len("ATA")]=="ATA":

counter=counter+1

print (counter)
0

I am trying to count the no. of occurrences of "ATA" in the dna_string This should give an answer of 3, but it gives 0 !!

SagarM
  • 135
  • 7

1 Answers1

0

You can try this regex solution:

import re
len(re.findall("((?=ATA))", dna_string))
# 3
Psidom
  • 209,562
  • 33
  • 339
  • 356