I want to count the results in each regex search against a file. I believe I'm populating a list and then looping through trying to get the value of a counter.
for file in XDTS:
    data_tag_regex = re.compile(r'data_tag=\"(.*?)\"')
    if file.endswith('.xdt'):
        xdt_file = open(file, 'r')
        for line in xdt_file:
            variable_names = data_tag_regex.findall(line)
            for index, variable_name in enumerate(variable_names):
                print(index)
				
                        
You have one match per line, and multiple lines match. Your
enumerate()call is starting from 0 each time because it is a new call for each new line:If you wanted to keep an index per match across all lines, you need to count independently: