FROM = 100 TILL = 100 TEMPLATE = """ def euler_XXX(): return 0 if __name__ == "__main__": solution = euler_XXX() print("eXXX.py: " + str(solution)) # assert(solution == 0) """ for i in range(FROM, TILL + 1): if i < 100: e = "0" + str(i) else: e = str(i) filename = "e" + e + ".py" with open(filename, "w") as f: s = TEMPLATE.replace("XXX", e) f.write(s)