Jul-27-2022, 10:27 AM
In a certain way the answer may have ever been in the remark; but still wondering if it's thet correct way
import os Path = str(os.getcwd()) n = 10 ##### def MyFunction(f, g, n): f.write(f"Square value of {n} is {n**2}\n") g.write(f"Cubic value of {n} is {n**3}\n") with open(Path + '/file1.txt', 'w') as f1, open(Path + '/file2.txt', 'w') as f2 : for i in range(1, n): print(f"i = {i}") MyFunction(f1, f2, i)