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 !!
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 !!
You can try this regex solution:
import re
len(re.findall("((?=ATA))", dna_string))
# 3