for num, val in (token[:2] for token in tokens):
    if num == tokenize.STRING:
        val = re.sub('{}', lambda L, c=count(): '{{{0}}}'.format(next(c)), val)
output.append((num, val))
print(tokenize.untokenize(output))
String formatting without index in python2.6