f = open('Otvet.txt', "w")
for i in range(1, 1001):
a = str(i) + " " + str(i ** 2) + " " + str(i ** 3)
print(a)
f.write(a)
f.write('\n')
f.close()
Otvet.txt
1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
...
997 994009 991026973
998 996004 994011992
999 998001 997002999
1000 1000000 1000000000