My program always return 'no match' and it's because it can't count the occurence of a substring. I have spent a lot of time trying to figure it out, so I hope someone can help me.
here's the function. The 'substring' argument is either AGATC, TTTTTTCT, AATG, TCTAG, GATA, TATC, GAAA or TCTG.
def analyse(substring): with open(sys.argv, 'r') as file2: dna = file2.read() substring_len = len(substring) check = 0 occurence = 0 i = 0 for i in range(0, len(dna), i + substring_len): check = 0 for j in range(substring_len): if j > substring_len: break elif dna[i + j] == substring[j]: check = check + 1 else: break if check == substring_len: occurence = occurence + 1 return occurence