def dots_repl(matchobject): global COUNTER numbered_dots = "{0} PSEUDOPSEUDOPSEUDO{2} {3}".format(matchobject.groups()[0], matchobject.groups()[1], COUNTER, matchobject.groups()[2]) COUNTER += 1 return numbered_dots