cs50 DNA, STR count in dna sequence function

  cs50, dna-sequence, python

I’m trying to write a function that does the arithmetic given a DNA sequence and a certain STR to count how many times the STR repeats in the DNA sequence and I started writing it but my function keeps returning 1, can you help me figure out why? Also, how can I pass the contents of a txt file as an argument for a function? So I don’t have to copy all the DNA sequence into the argument.

from cs50 import get_string
from sys import argv

def str_counter(DNA,STR):
    total = 0
    i = 0
    j = 4
    for STR in DNA:
        if STR == DNA[i:j]:
            total += 1
            i += 1
            j += 1
    return total


Source: Python Questions